Physical Random Number Generator

   Why? A recent story in Science (26 February 2021) caught my eye. It described a method of generating (true) random numbers at very high speed using laser light. I had previously encountered explanations of quantum random numbers, for example, at this web page from The Australian National University.  Another fascinating project, called HotBits, addresses the subject at an amateur level.

    Anything having to do with quantum physics may be inaccessible to non-specialists. However, on reading about physical generation of random numbers, and in particular about the kind that relies on the fundamental randomness of nature at its smallest scale, I wondered if it would be feasible to generate good quality random numbers from electronically produced so-called ‘white’ noise. While I know almost nothing about physics, I do know a little about noise. As an amateur radio operator I have observed many different types of noise that affect the quality of radio reception. The diagram below summarizes my first effort at producing random numbers from electronically-produced noise.

Project Outline

   Generating noise: I constructed the circuit described on this page, substituting a C1815 transistor for the specified BC182L, which I did not have. Noise is produced at the reverse biased emitter-base junction of this transistor. (The collector is not connected.) The rest of the circuit is identical to the referenced one, except that instead of 9 volts I used a 12 volt battery for power. The circuit works fine with a bench power supply or brick, but I thought a battery would avoid possible power supply hum. See also the composite circuit diagram below.

Transistor junction

    I also experimented with generating white noise using a Zener diode (this circuit). However, the audio part of the generated spectrum included an intermittent ‘popping’ on top of otherwise uniform-sounding white noise. In an effort to get rid of the ‘pops’ I slowly reduced power-supply voltage toward the diode’s Zener voltage (below which there is no noise). But while noise amplitude steadily decreased as voltage was lowered, the relative amplitude of ‘pops’ was unaffected. Other Zener diodes also produced the symptom, which remains unexplained for the present.

Zener diode

Noise spectrumNot Radioactive   Amplifying and Conditioning: In this project noise itself is the signal of interest. Thus instead of seeking to improve signal-to-noise ratio, the challenge was to condition the noise for further processing. In a previous project and this related one I had repurposed the pre-amplifier section of the Four State QRP Group Frequency Mite kit, so I thought to use the same amplifier circuit again for the present project. Once again transistors were substituted, 2N3904’s in place of the 2N4401’s in the 4SQRP kit—No 2N4401’s were available from the parts bin.  After amplification, peak noise amplitude was sufficient to drive transistor-transistor logic gate inputs (TTL).

    The pre-amplifier shared power from the 5-volt pin of an Arduino Uno, which was powered via the USB cable from the desktop computer. Two series NAND gates buffered the pre-amp output, which in turn drove the input of a 74HC4040 12-bit counter IC. I experimented with different divisors to ascertain a value that produced sufficient variability of inter-pulse times in Arduino, and at reasonable speed (frequency). This led to selecting Q9 as the divisor, although neighboring divisors also work. Q9 output was then fed through NAND gates (same as the input) to an Arduino interrupt pin (digital I/O pin 2). These component circuits and their interconnections are shown in the composite schematic below.

White noise with amplification and conditioning

   Harvesting data: A very simple Arduino sketch captures time data and transmits time deltas to the desktop computer. On the computer end, the RS232 program Termite receives the serial data stream, although the Arduino IDE’s serial monitor would work as well. Having ascertained an approximate rate of data generation, I let the program run long enough to produce a target quantity of data, and then copied and pasted time deltas from Termite (or the IDE’s serial monitor) to a text file.

Receiving time deltas

    From the time deltas text file, data are then processed using an analog of the algorithm that HotBits uses to generate ‘true’ random numbers (see link above), but implemented in a different programming language. This times-to-numbers processing step is easy and could be coded in any programming language. My improvised code may serve as a guide (like pseudo-code) for processing steps that produce datasets of random numbers for testing/analysis using the dieharder suite (Linux) or the NIST random number statistical assessment tool ‘assess’.

Final summary from a NIST run

   Speed and Quality: If research grade random number generators are ‘ultra-high bandwidth’, then this project would qualify as an ‘ultra-slow’ physical random number generator. In early testing the procedure generated fewer than 60 bits per second. Now it is about 110 bits per second. With luck, production rate may continue to improve a little, as parameters are tweaked, or further adjustments are made to the algorithm.

Beginning of random binary data file

    The largest dataset generated in a single run (so-far) is 1,628,240 bits (about 4 hours). This fairly large dataset passed all of the more than 150 NIST suite components and had just 4 ‘weak’ findings from the dieharder suite. A small number of weak results may be expected in a large pool of probability calculations. Other smaller datasets also passed all NIST assess tests, with no more than 1 to 3 dieharder ‘weak’ findings.

   Interference: For this project I made throw-away circuits on breadboards, with no effort to shield them from interference. For serious work it would be necessary to construct more robust circuits, and with proper shielding, so that other noise sources would not confound the intentionally generated—relatively uniform—broadband noise. During testing, RFI was found to affect the noise spectrum. Even household laundry appliances appeared to have an effect. To avoid contamination from such non-random sources, data acquisition was limited to quiet periods.

Unshielded test setup

   Summary: Pseudo-random numbers (glossary below) are widely used, and of course, are part of the programmer’s toolkit. In some contexts physical events may be used to seed a pseudo-random number generator, for example, the time of a keypress or mouse click. I do not know what sorts of applications require physical random numbers, or the extreme of ‘true’ randomness, in place of the common pseudo-random sequences. The lottery relies on a physical process (bouncing ping-pong balls), but do any mathematical or physical investigations require such numbers? Maybe it is a matter of confidence. The knowledge that a pseudo-random sequence is reproducible, however remote the possibility of that happening, causes our minds to drift randomly toward alternative options.

Projects Home

Mini-Glossary: [Made-up definitions, not claimed to be rigorous.]

Pseudo-random number (RN) - produced by a mathematical algorithm that was possibly seeded from a random event. Distributions of pseudo-random numbers pass multiple tests of randomness, but in principle can be reproduced from knowledge of the algorithm and its seed.

Physical random number (PRN) - produced from a putatively random physical process or mixture of such sources, such as resistor noise.

True random number (TRN) - AKA Quantum Random Number.. generated from a fundamentally random physical process, such as the time of decay of a radioactive atom.

Project descriptions on this page are intended for entertainment only. The author makes no claim as to the accuracy or completeness of the information presented. In no event will the author be liable for any damages, lost effort, inability to carry out a similar project, or to reproduce a claimed result, or anything else relating to a decision to use the information on this page.