**What are random numbers?**

Random numbers are sequences of numbers that have no pattern, and are very important in many areas of science and technology. The techniques used for generating them are interesting and there are many interesting problems associated with their generation and use. Perhaps the best known source of random numbers is the six-sided die used in many games – when the die is thrown there is an equal probability of one of the numbers from one to six coming up (assuming that the die is properly made). Another familiar example is the machine used in lottery draws. Another source of numbers that appear to be random is a computer program. It is quite easy to write such a program, the numbers generated are called pseudo-random numbers, because it is impossible to generate true random numbers using an algorithm.

**Testing for randomness**

Given a sequence of numbers, how do we know that they are random? There are a number of statistical tests that have been developed for this purpose, the simplest is the Runs Test. Let’s assume that we have tossed a coin 10 times, and we get the sequence HHTHHHTTTT.

We would like to establish if the sequence is random so we see how many runs we have – sequences like HH and TTTT. The more runs we have that are the same, the more likely it is that the sequence is random. Interestingly, it isn’t possible to prove conclusively that a given sequence is truly random, as we don’t know that, given enough time, it will not eventually repeat.

**Pseudo-random number generation**

Pseudo-random numbers are usually generated using a mathematical technique called a linear-congruential generator:

Xn+1 = (aXn + b) mod m

Provided that a, b and m are properly selected, a sequence of numbers is generated that satisfies the various tests for randomness. However, it won’t be truly random, as it will eventually repeat, although it might take several million iterations before that happens. Such random number generators are usually seeded with a starting number, and different seeds will start the generator at different points in the sequence. If this isn’t done, the generator will produce the same sequence each time it is used. Such random number generators are provided in most compilers.

The fact that they are completely determinate can actually be quite useful in applications like simulation. They have the disadvantage, if used in areas such as encryption, that agencies such as GCHQ can easily decrypt your message, by assuming that a certain compiler was used in the encryption program. You could make things difficult for them by creating your own generator if you are doing something naughty.

Such sequences can also be generated by hardware, by using a shift register and one or more feedback loops with XOR operations.

**True random numbers**

True random numbers are generated by a physical process of some sort, as has already been mentioned. Devices like dice and lottery machines are fine if a limited sequence is required, but are not feasible if thousands or millions of random numbers are required, so electronic techniques are generally used. A popular technique which is often used by radio amateurs is the random noise emitted by a Zener diode, in a noise generator for optimising receiver noise factor. Some simple electronics can be used with a noise generator to provide a random bit stream to a micro-controller input which can be converted into random numbers, that can then be sent to a PC via an RS-232 or USB interface. Such random number generators can be very useful, provided that they satisfy the statistical tests for randomness. An interesting related technique that I have tried for myself uses the Parallax Propeller multi-core controller.

The Propeller incorporates an oscillator which is used in the PLL for generating a very fast clock and one of the developers found that the jitter inherent in this oscillator when it is unlocked formed the basis for a good source of random numbers. Other random number generators have been developed using radio noise, radioactive decay and even the changing shapes of blobs in a lava lamp, using images captured using a camera.

The ultimate source of random numbers is the Quantis unit made by idQuantique in Switzerland. A laser and attenuator is used to generate single photons (light particles) which are fired at a half-silvered mirror, mounted at 45 degrees to the source. A single photon detector is positioned behind the mirror to detect photons passing straight through, and another detector is positioned where it can detect photons reflected by the mirror. According to quantum theory, the photon behaviour is completely random and the output from the detectors is processed to give a random bit stream. These units are not particularly expensive at about £600. My Propeller system cost me about £20 to build, however.

**Where are they used?**

Pseudo-random number generators are quite ubiquitous, they are even used in the Internet protocols. True random number generators are starting to be used in high-security quantum cryptographic systems, as they can be used in a similar way to the one-time pad that is popular in espionage circles, with the advantage that any interference with the message can be detected.

Perhaps the weirdest application of a random number generator is the series of experiments performed at the Princeton Engineering Anomalies Research (PEAR) laboratory. Over a period of 28 years a number of researchers have investigated whether people could influence the behaviour of random number generators by telekinesis – willing them to produce more ones than zeros or vice versa. They claim to have achieved statistically significant results, but no-one else has been able to replicate their experiments and the PEAR people couldn’t even get their techniques to work in a different laboratory. They appear to believe that consciousness is a quantum phenomenon, and therefore it is possible that the brain can somehow influence the behaviour of another quantum system. Unfortunately, they haven’t been able to convince anyone else in the scientific community of the validity of their results, and the PEAR laboratory was closed last year.

Leon Heller, G1HSM re-published from the Vital Spark, August 2008.

Return to the index of Vital Spark articles.