Go Down

Topic: True Random Number library (Read 7196 times) previous topic - next topic


Tinker.it! have just released a true random number library for Arduino: TrueRandom.

It generates true random numbers, not pseudo-random numbers. So its ideal for generating unique ID numbers or MAC addresses, gaming or cryptography.

Launch of TrueRandom: http://tinker.it/now/2010/03/16/more-random-than-random/

TrueRandom on Google Code: http://code.google.com/p/tinkerit/wiki/TrueRandom


That looks very nice!

Any reason for not supporting the Mega AVR1280 chip, seems it would only require some if defined statements, etc? As I own multiple Arduino boards I like to use stuff portable to all the Arduino IDE supported chips.

Also any benchmark on how many random numbers a second the library can supply, i.e. what is the speed and code size hit over the standard Arduino pseudo-random number generator?

Also any testing of the generated numbers against a random number evaluator program?



TrueRandom doesn't support the Mega1280 yet purely due to time constraints. I hope to have 1280 support for the next release.

As for benchmarks- check out the included Benchmark example. Expect about 100 random numbers per second, or 1000 per second for coin flips (TrueRandom.random(2)).

If you need faster numbers, you can use TrueRandom to seed the pseudorandom number generator - there is an example for that too.

No testing with random number quality tests yet- but that is purely a time issue. Hopefully I can get some tests done for version 2.


Cool, I will be sure to follow your progress.



Looks nice, but did you test it? I once tested random number generators with the diehard test suite http://en.wikipedia.org/wiki/Diehard_tests. What I found was that all tested random number generators were flawed. This included random number generators from the text book as well as one certified random number generator. Certified means my company paid real money to an math professor with expertise in this field to check it.

We then switched to the Mersenne Twister.

Since then I do not trust any implementation any more unless I am told how it was tested.

Today I would test them using dieharder: http://www.phy.duke.edu/~rgb/General/dieharder.php

Did you run any such tests on your "true" random number generator?

Check out my experiments http://blog.blinkenlight.net


Mar 16, 2010, 09:37 pm Last Edit: Mar 16, 2010, 09:42 pm by Cathedrow Reason: 1
Udo: No, as I have already stated, no random number tests yet. Yes, you should regard it with suspicion for crypto and gaming applications until testing is complete. You have access to the library though, so by all means test it yourself. It looks like Diehard needs some big data sets though. I'd also suggest having a look at the random.org tests: http://www.random.org/analysis/ , as they seem to prefer the more actively maintained NIST tests: http://csrc.nist.gov/groups/ST/toolkit/rng/index.html

However, in its current state, it is still very useful for unique identifiers, discriminating different Arduinos with identical software, and of course amusement purposes such as die rolls and magic 8 balls.

Coding Badly

Why do you apply the Von Neumann algorithm twice?


Oops, sorry, I missed the answer to retrolefty.
Check out my experiments http://blog.blinkenlight.net


Von Neumann corrects for a static bit bias (eg. 00000000). However it doesn't correct for oscillating bit bias (eg. 01010101). As electrical noise could influence the original measurement, and some of that electrical noise includes binary counters, it seemed prudent to add that extra layer.

I'm sure once proper random number testing is running it will assist in determining exactly how much of which type of whitening to use.


Mar 16, 2010, 10:07 pm Last Edit: Mar 16, 2010, 10:09 pm by udoklein Reason: 1
Yep, you need to test. And you should test at least under three different conditions:

1) Battery powered
2) USB powered
3) AC adapter powered

It might happen that you get suprisingly different results.

Check out my experiments http://blog.blinkenlight.net


Has anyone tried to make the code changes to allow this to work with the Mega?

Go Up