Random number generator – by Leon G1HSM

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.

G3MGQ’s Month on the Air

Prepared by the clubs RSGB trainer, G3MGQ, you will find the latest DX contests including the ones to shoot for as well as ones to give a wide berth. Why not download the latest edition of Month on the Air and enjoy your DX just that little bit more.

Become a member of HERC

Join the Hastings Electronics and Radio Club.

Why not join one of the largest and most established Radio clubs in the South East of England? Very low joining cost, and free for a year to new licencees.

Vital Spark Archive

Vital Spark newsletter articles

Take a look through a large selection of articles written by club members over the years which have been published in the monthly Vital Spark newsletter .

Used Ham Radio Equipment

View HERC's Used Ham Radio Equipment for sale list..

Every four weeks, HERC's Used Ham Radio Equipment for sale list is updated on the site. Bookmark the gear for sale page to re-visit easily and take advantage of the used equipment on sale through the club.

Club Photographs

HERC Image Galleries.

Here is the official HERC photograph archive which contains multiple image galleries spanning several decades since the club was formed many years ago. Enjoy the images!

UK Amateur Radio Repeaters

UK repeaters

Click button above for full list, or a local repeater callsign below for info.

GB3EB 2m in Uckfield- Active
MB6EB 2m DStar Node in Eastbourne - Active
MB6RY Wires-X DigiGate in Broad Oak - Active
GB3HE 70cm in Hastings - Active
GB7HE 70cm DStar in Hastings - Coming soon
GB3ZX 70cm in Eastbourne - Low Power
GB3JT 23cm ATV in Hastings - NoV cleared
GB7RY 70cm X-Wires Repeater Rye - Active
GB7ES Eastbourne - DSTAR Rpt. - Active
GB3ES 2m in Hastings - Active

For a complete list of repeaters, head over to
the UK Amateur Radio repeaters list.

Popular pages

Get your amateur radio licence - Find out more about amateur radio licence training.
Month on the Air - G3MGQ's popular monthly DX contest/expedition list.
Wilf Gaye Memorial Cup - The clubs annual operating event in the memory of Wilf Gaye M0GYE.
St. Richard's College Buildathon/STEM/ARISS - HERC attends St. Richard's Catholic College for their various events surrounding the Tim Peake ARISS contact.
G3BDQ - John Hey's Rare QSL Cards.
Sussex Electronics Radio Fair - SERF Sussex Electronics Radio Fair 2016.
Vital Spark - A selection of articles re-published from the Vital Spark.
RSGB News - Find out how to get RSGB news on your mobile or PC.
Experimenters Corner - A selection of Proteus projects by Bob Gornal (G7DME)
BBADL - Bath Based Distance Learning Course.
Conquest Hospital Radio - Presented by HERC member Antony (G4CUS).
Radio Rallies 2016 - An up to date list of radio rallies scheduled for 2016.
Club QSL Cards - A selection of QSL cards the club has received over the years.
Other Newsletters - Excellent newsletters and magazines from other clubs.
TX Factor episodes - Take a look at the TX Factors YouTube videos.
John Taplin - A bio of the late John Taplin.

Amateur Radio Resources

Other Radio Clubs & RAYNET

BSARS - Brede Steam Amateur Radio Society

RAYNET - The Hastings and Rother RAYNET Group.

HERC members sites

Sigord - Gordon Sweet
Hastings Radio Comms - Andrew Haas-Campbell
Hoofbags - Liz Costa