Go Down

### Topic: Good source of random numbers? (Read 10490 times)previous topic - next topic

#### xolroc

##### Jun 14, 2012, 07:23 pm
The documentation on random() and randomSeed() suggest using the input from an unconnected analog pin, however I suspect this isn't remotely random enough for any serious purposes--you've only got 1024 possible seeds, and probably only about 100 in practice!  What do you suggest would be a good source of random data?  I'm considering using floating-point operations with a series of trigonometric functions, but would this even work?  I could use real-world data, but I'd prefer not to use up any pins.

#### AWOL

#1
##### Jun 14, 2012, 07:32 pm
Americium from a smoke detector and a G-M tube
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### wildbill

#2
##### Jun 14, 2012, 07:33 pm
Any one who considers arithmetical methods of producing random digits is, of course, in a state of sin - John von Neumann

If you really want better randomness, you pretty much have to get it from some external physical source.

#### cmiyc

#3
##### Jun 14, 2012, 07:35 pm
You might be interested in this recent discussion:
http://arduino.cc/forum/index.php/topic,108380.0.html
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

#### wanderson

#4
##### Jun 14, 2012, 07:41 pmLast Edit: Jun 14, 2012, 07:43 pm by wanderson Reason: 1
The library mentioned in the previous discussion is available from a link in my signature block.  It uses the jitter associated with the watchdog timer and timer 1 to produce what appears so far to be a very random stream of numbers.  It only produces about 8 bytes per seconds, but if you need more it can be used to seed a pseudo-random generator, either the one built into the arduino library or perhaps one of the better ones such as blub-blub... In addition that page has information/source on two other hardware based methods for generating random numbers.  I have used geiger counters as well as avalanche noise and can provide test results for both if your interested.

#### xolroc

#5
##### Jun 14, 2012, 07:41 pm

Americium from a smoke detector and a G-M tube

The legality of that method seems rather questionable to me....  Besides, I don't have a Geiger-Mueller tube.

You might be interested in this recent discussion:
http://arduino.cc/forum/index.php/topic,108380.0.html

Thanks, I'll use that library!  Internal jitter is exactly the sort of thing I was looking for.

#### AWOL

#6
##### Jun 14, 2012, 07:45 pm
Quote
The legality of that method seems rather questionable to me..

Can't think of a good reason why it should be, unless dismantling a smoke detector is in some way illegal.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### clvrmnky

#7
##### Jun 14, 2012, 08:40 pm

Quote
The legality of that method seems rather questionable to me..

Can't think of a good reason why it should be, unless dismantling a smoke detector is in some way illegal.

Am-241 is exempt from most laws regarding the safety and handling of radioactive materiel. It depends on your locality, of course, and some locales have laws that say this with the caveat that you can possess it as long as it remains in the smoke detector sold to you untampered.

But in a great number of localities you can even dispose of these smoke detectors in regular household trash. You can eat the pellet w/o really causing yourself significant damage (though, of course, no one is suggesting it is a /good/ idea to do so -- prudence and intelligent behaviour is still the rule.)

The fact is that some types of collectable Fiestaware are more radioactive than the small amount of Am-241 in modern detectors.

But, it is all a matter of degree. If you are going to be a Radioactive Boy Scout, it doesn't matter how legal playing with Am-241 is. A superfund site is a still a superfund site!
I yield() for co-routines.

#8
##### Jun 14, 2012, 09:42 pm
It only produces about 8 bytes per seconds, but if you need more it can be used to seed a pseudo-random generator, either the one built into the arduino library

Bah!  That one barely qualifies as "random number generator".

Quote
or perhaps one of the better ones such as blub-blub...

JKISS32 (the "J" and "32" are important!) from this paper...

http://www.cs.ucl.ac.uk/staff/d.jones/GoodPracticeRNG.pdf

...is an excellent choice.  It is faster, smaller, and much better quality than the AVR Libc generator.  The only downside is the extra SRAM needed (20 bytes versus 4).

#### majenko

#9
##### Jun 14, 2012, 09:49 pm
One of the best generally accepted sources of entropy is the noise generated at the breakdown of a reverse biased zener diode. http://electronicdesign.com/article/test-and-measurement/wide-band-analog-white-noise-generator6356

You can also make reasonable white noise to use as an entropy source by massively amplifying the thermal noise in a resistor using an op-amp.

#### xolroc

#10
##### Jun 14, 2012, 11:21 pm
I suppose, while we're on the topic of noise, one could use the noise produced by a broken component that still erratically conducts?  Such as a capacitor that's undergone dielectric breakdown, or a diode that's avalanched one too many times?

#### Grumpy_Mike

#11
##### Jun 14, 2012, 11:33 pm
A good random firing cell I made in the 60s, consisted of a small tube with some cotton wool soaked in Silver Nitrate solution.

Two electrodes are placed into this.
A voltage across the electrodes causes dendrites of silver to form on the cotton wool. When they join up it causes a short that melts the dendrites and causes a small pulse to be produced. The current is very low, and the time between pulses is random.

#12
##### Jun 14, 2012, 11:48 pm
I suppose, while we're on the topic of noise, one could use the noise produced by a broken component that still erratically conducts?  Such as a capacitor that's undergone dielectric breakdown, or a diode that's avalanched one too many times?

You have to run the test.  Things that seem random to us often are not.  RANDU and TrueRandom are great examples.

A good random firing cell I made in the 60s, consisted of a small tube with some cotton wool soaked in Silver Nitrate solution.

Cool experiment.  Unfortunately, it may be a bit expensive these days...  SINI-1542-42  25g  £29.12

#### xolroc

#13
##### Jun 15, 2012, 12:03 am
http://www.flinnsci.com/store/Scripts/prodView.asp?idproduct=21189 there, one hundred milliliters of 0.1M silver nitrate, for 13.55.  I'm sure there are some cheaper ways to do this though.

#### robtillaart

#14
##### Jun 15, 2012, 08:16 am

- http://www.random.org/integers/ - ?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up