Pages: [1] 2 3 4   Go Down
Author Topic: Good source of random numbers?  (Read 4385 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 135
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26285
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Americium from a smoke detector and a G-M tube
Logged

"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.

New Jersey
Offline Offline
Faraday Member
**
Karma: 67
Posts: 3694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Dallas, Texas
Offline Offline
God Member
*****
Karma: 31
Posts: 887
Old, decrepit curmugeon
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: June 14, 2012, 12:43:54 pm by wanderson » Logged

New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

Offline Offline
Full Member
***
Karma: 0
Posts: 135
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26285
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Canada
Offline Offline
Full Member
***
Karma: 0
Posts: 246
Code Monkey
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

I yield() for co-routines.

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 207
Posts: 12910
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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".   smiley-wink

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).
Logged

UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Offline Offline
Full Member
***
Karma: 0
Posts: 135
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34143
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 207
Posts: 12910
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 135
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13705
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


- http://www.random.org/integers/ - ?
Logged

Rob Tillaart

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

Pages: [1] 2 3 4   Go Up
Jump to: