Print Shortlink

Yay!!! New Arduino RNG

Here are the results of the new random number generator I built yesterday.
The old random number generator was not putting out an unbiased stream of bits.
I tried using debiasing algorithms with the old generator but it was not enough.


Entropy is how random a piece of data is, basically how many random bits are in one byte.
True randomness is 8.0 bits per byte.
We are really close. Yay!!! Five Nines!!! Statistically Significant!!! Yay!!!
Entropy = 7.999993 bits per byte.

Basically says how small you could get it with a zip file
Zip files and pretty much all compression schemes do their job by removing patterned and repeating sequences of bits
Optimum compression would reduce the size
of this 25874432 byte file by 0 percent.

Can’t quite figure out what a good figure is on this test
but 50 percent with an average of 254.05 seems good
Chi square distribution for 25874432 samples is 254.05, and randomly
would exceed this value 50.50 percent of the times.

Do the bytes average out to be in the middle
Tests the ratio of ones to zeros in the bit stream
Arithmetic mean value of data bytes is 127.4920 (127.5 = random).

Can we calculate Pi correctly, if so, we pass. Yay for Pi!!! Yay for Pie!!!
Monte Carlo value for Pi is 3.141568568 (error 0.00 percent).

Assuming this tests byte to byte similarities
Which means is the current byte similar to the last one
Serial correlation coefficient is -0.000016 (totally uncorrelated = 0.0).


Random class for Arduino

Logger class for Arduino


The diode is a 12.1V zener and C1 is a ceramic disc type capacitor. The zener diode’s part number is an artefact of the designer I used so you can ignore it.

Full Size

3 Responses

  1. Birk

    Excellent results! I’m eagerly awaiting your links.

  2. BeepMeep

    Do you know whether the 2N3904 transistor can be safely replaced by a 2N2222?
    According to Wikipedia, it has very similar characteristics, but as a total beginner in electronics, I’m a bit doubtful.

    Anyhow, thanks for your efforts you’ve put in this TRNG-project. Beautiful outcome! 🙂

Leave a Reply

%d bloggers like this: