I can't understand how could computer make random numbers. I mean what piece of hardware can do this? and does the computer has only one source to do this and all the programming languages use that? Thanks in advance.
2 Answers
The short answer is that computers can't easily make truly random numbers. There are a couple ways to generate random numbers, though, some fast but not random, and some slow but true...
Pseudo-Random Generators
Most low-level languages (Namely, C) have built in functionality that allows them to psuedo generate random numbers, but this is not true random number generation. It works by starting with a "seed" value, an initial string of numbers, and then modifying this seed, over and over again, to create a "random" string.
They fall short in that, with the right seed and factors, conditions can be created to force a certain number to be generated. Also, due to the nature of the generation, when graphed, the results will not be evenly distributed. As mentioned by the above answerer, there are things a programmer can do to make it more random, but the method can not be truly random, for the above reasons. An example is the random number generator in most programming languages. It is hard-coded, and is performed in the CPU.
Entropy Generators
Random numbers that work through entropy generation work by measuring a type of entropy (disorder, or, as I have heard it defined, chaos @duffymo has informed me that chaos is not a good synonym. Sorry!) that is presumed to be random. Atmospheric and thermal noise are common things measured. They are generally considered to be "better" than the above choice, as they are, for the most part, closer to true randomness. One issue is that they are slow - numbers can not be generated unless enough entropy is harvested. An example is random.org, an atmospheric noise entropacal random number generator (say that 10 times fast!). It is performed by whatever piece of hardware makes the measurement of entropy.
Quantum Generators
A subset of entropy generators, quantum generators measure quantum factors (factors not used in classical physics), such as the spin of particles to determine a number. A downside is that true quantum generators are expensive. An example is this piece of hardware which uses the path of a photon to determine a number.
Hope this helps!

- 7,369
- 11
- 45
- 64
-
Entropy and chaos are two different ideas entirely. Not synonyms. – duffymo Jul 31 '14 at 14:27
-
@duffymo isn't entropy is a measure of chaos? (disregarding information theory's definition of entropy) – om-nom-nom Jul 31 '14 at 14:33
-
Chaos implies non-linearity; you can still produce entropy in linear systems. They are not the same. Entropy is an older idea from thermodynamics. Chaos was a fashionable term for some discoveries in the 1980s. – duffymo Jul 31 '14 at 14:52
-
@duffymo thanks for the clarification, and apologies for the incorrect definition. – rocket101 Jul 31 '14 at 19:23
-
No apology needed; at least you're thinking. – duffymo Jul 31 '14 at 22:18
It can be hardware, but most languages like Java and C# use a software construct best explained by Donald Knuth in his opus "The Art of Computer Programming": linear congruential generator.
As you can imagine, there are problems with these approaches.
There are attempts to improve it (e.g. Mersenne Twister).
There are extensive statistical tests to assess a given random number generation algorithm called the Diehard Tests. (I always picture big vehicles in a snowstorm being cranked in the cold by honking batteries when I hear about those tests.)
I'd be willing to bet that the period on these pseudo random number generators is more than adequate for your applications.
The best way to generate a truly random number is to use a quantum process from nature in hardware.

- 305,152
- 44
- 369
- 561