Offline
Full Member
Karma: 0
Posts: 135
|
 |
« on: June 14, 2012, 12:23:03 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.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 136
Posts: 18995
I don't think you connected the grounds, Dave.
|
 |
« Reply #1 on: June 14, 2012, 12:32:37 pm » |
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.
|
|
|
|
New Jersey
Offline
Edison Member
Karma: 24
Posts: 2345
|
 |
« Reply #2 on: June 14, 2012, 12:33:25 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.
|
|
|
|
|
Logged
|
|
|
|
|
Austin, TX
Online
Faraday Member
Karma: 41
Posts: 5161
CMiYC
|
 |
« Reply #3 on: June 14, 2012, 12:35:12 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
Dallas, Texas
Offline
God Member
Karma: 1
Posts: 690
Old, decrepit curmugeon
|
 |
« Reply #4 on: June 14, 2012, 12:41:08 pm » |
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
|
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 135
|
 |
« Reply #5 on: June 14, 2012, 12:41:59 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. Thanks, I'll use that library! Internal jitter is exactly the sort of thing I was looking for.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 136
Posts: 18995
I don't think you connected the grounds, Dave.
|
 |
« Reply #6 on: June 14, 2012, 12:45:47 pm » |
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.
|
|
|
|
Canada
Offline
Full Member
Karma: 0
Posts: 246
Code Monkey
|
 |
« Reply #7 on: June 14, 2012, 01:40:46 pm » |
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
Shannon Member
Karma: 116
Posts: 10130
|
 |
« Reply #8 on: June 14, 2012, 02:42:20 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".  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
Edison Member
Karma: 41
Posts: 2170
What a host of balls she had seen: gaity, the brass buttons...
|
 |
« Reply #9 on: June 14, 2012, 02:49:51 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-generator6356You 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
|
|
|
|
|
Offline
Full Member
Karma: 0
Posts: 135
|
 |
« Reply #10 on: June 14, 2012, 04:21:04 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?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25381
Solder is electric glue
|
 |
« Reply #11 on: June 14, 2012, 04:33:54 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.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 116
Posts: 10130
|
 |
« Reply #12 on: June 14, 2012, 04:48:07 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
|
|
|
|
|
Logged
|
|
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 86
Posts: 9355
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #14 on: June 15, 2012, 01:16:01 am » |
|
|
|
|
|
Logged
|
|
|
|
|
|