John von Neumann, computer pioneer said:

Any one who considers arithmetical methods of producing random digits is, of course, in a state of sin.

Using predictable circuits (such as we want to use in a computer) always produces a predictable result - if you know the program and the inputs to the program.

To generate "truly" random numbers you need a "non-predictable"

hardware circuit, such as:

- measuring the voltage of a Zener diode, which generates random noise

- quantum effects like measuring the rate of radioactive decay

- using a number of unstable circuits, like a ring oscillator

- measuring the "shot noise" as single electrons travel through a semiconductor

- recording the instants in time that someone types a character on a computer keyboard

- recording the instants in time that a computer disk returns data to memory

Some operating systems collect a pool of random numbers from operating system events that people can dip into when they need to generate an unknown encryption key for a new https: session, or are running a simulation, for example. The risk is that if users demand a lot of randomness (eg for running a large simulation) but are contributing little randomness, the pool will run dry. So many applications dip into the pool for a "seed", but then generate their own random numbers.

Some new computer chips have hardware to generate random numbers built in (like 3 above), which will help them generate an unlimited supply of random numbers for these purposes.

Most computer languages have a built-in random number generator which is purely software. This depends on having a "random" seed, and then repeatedly applying a program which modifies it to produce a new number which looks quite different from the previous number (and which can be mathematically proved to be randomly different in every bit position). A good random number generator will not generate the same sequence of numbers for a very long time.

One of the

more traditional arithmetic methods takes a starting seed number X

_{0}, and applies the formula X

_{n+1}=(X

_{n}*A + C) modulo M

By carefully selecting the numbers A, C and M (eg they must be relatively prime), it is possible to quickly generate a sequence which does not repeat for billions of numbers, and passes many tests for randomness - unless you

happen to know A, C and M.

There are schemes which combine two or more random number generators in a table of numbers to make a sequence which will not repeat within the lifetime of the Earth.

To ensure that the numbers collected from many sources appear more random, some schemes scramble the numbers they generate. Unfortunately, if the random number generator source suddenly stops generating new random numbers (eg your Zener diode short-circuits), this "

whitening" process may give the illusion that it is still working properly.