Random Number Generator

I would like to build a random number generator based on thermal noise, and hope to get some advice on that. I'd like a small device that generates a number from 1 to 6 (simulating the toss of a die), and has a single-digit display. No need for anything fancier than that. Well, maybe six LEDs to be pips, I'll have to decide.

I have vague recollections of reading about these, but don't really recall the mechanism. I suppose I'd start with a resistor on a comparator, generating a noisy sequence of +V or ground. And I imagined incrementing a three bit counter with each +V for some period of time, like a tenth of a second, and resetting to zero each time the highest count is reached. For some period of time that ensures it will roll over many times before it stops. And then interpreting that on a single digit display.

Seems easy enough, but I don't know how naive the design is. Can a counter just count that kind of input, or do I need a sample-and-hold or something? Is there a better way to design it? What parts, like for counting and display, can be bought off-the-shelf to make it easier?

Lay some wisdom on me, engineering people. Thanks.

Reply to
Greg Hansen
Loading thread data ...

Do you need something so complex for something so simple? Why not just implement a LFSR in a PIC? It'll look random enough. It won't be truly random.

Reply to
a7yvm109gf5d1

Need noise??

1) Buy one of those mini AM radio's and tune to something noisy. 2) Tweek a zener and amplify it 3) Tap high frequency noise off the AC power 4) Amplify everything off an antenna but fc>~120Hz 5) Use the most noisy op amp available (use carbon resistors too)

What wrong with just using a HF oscillator to "tumble the dice"? D from BC

Reply to
D from BC

Make a crappy 1 MHz oscillator, schmitt trigger or something. Make a

6-state counter that drives your display. When a button is pushed, the oscillator drives the counter and the led's blur dimly in a pleasing manner. When your finger lets go, the counter stops at a perfectly random state.

John

Reply to
John Larkin

hmmm... I did something very similar years ago by feeding the noise from a zener into an amplifier and flash sampling with an ADC. Quite a simple circuit if memory serves. if the Thermal noise option is not obligatory, you might consider this, no?

Reply to
feebo

You won't get uniformly distributed numbers this way. The bin widths of the A/D aren't uniform, and neither is the amplitude distribution of the noise. If you really want the randomness to be controlled by noise, then a noise-gated variant of John's counter idea would probably do quite a good job. Something like amplified noise, driving a Schmitt trigger, ANDed with the clock signal, driving a counter for a fixed period. The reason this is better is that any small change in the average duty cycle will make the counter go through many many complete cycles, so all the nonuniformities get completely smeared out.

Another approach would be to sample the noise using a many-bit single-slope A/D to get very very uniform bin widths. The last stage of the counter would have to be %6 not %8, but that's not too hard. The LSBs would be random enough for most uses. In any case, John's idea of counting a fast clock for a random interval is the ticket.

Cheers,

Phil Hobbs

Reply to
Phil Hobbs

Amateurs like me always have ideas for generating truly random numbers, most of which are shot down by the crypto experts who manage to tease out some statistical imperfection or autocorrelation in the sequence.

That said, why not make a zener-based noise source, and run it through a comparator. That will have all sorts of bad statistics because of symmetry and bandwidth issues. But now build a long-cycle pseudorandom shift register and xor the zener noise stream somewhere into its guts. What happens is that the shift register state sequence randomly hops all over the place, never staying long enough in the series to even hint at the sequence. Wouldn't that be crypto-grade noise?

John

Reply to
John Larkin

Yup ..that's a little like burning wood on a gas stove that's floating in a volcano during a super nova. "Is it hot enough?" :)

I dreamed up a crazyass noise circuit some years ago that used a dual filament car lamp... I tried it out and it makes a really nice hisssssss.. Any guesses how I did that???

D from BC

Reply to
D from BC

No, it wouldn't.

Calculating a hash of the imperfect noise is the standard way of generating of the quality random numbers. LSFR is an extremely weak hash; you should use a nonlinear function. However the most important is not to take more bits from the hash then the entropy of the source of the original noise.

Vladimir Vassilevsky

DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

I'm an amateur too--I've just spent enough hours investigating photocurrent noise statistics experimentally that I know that as long as it's really fundamental physics involved, and not just device parameters, that theory stuff really works. It works as in shot noise being really really Gaussian, within +- 0.1 dB out to threshold crossing rates of 10^-11 times the bandwidth, as measured with a MAX900 comparator and a 10-turn pot in a die-cast aluminum box. That impressed me, for sure. (It probably worked further out, but the last data point was 2 counts in 69 hours in a 1 MHz bandwidth...1 dB further would have taken a _year_.) (There was a closely related discussion in sci.optics a few days ago.)

Donald Knuth says somewhere in his books that "you can't make good random numbers by using a random method." Some mixture of poor-quality physicsy noise with indifferent-quality pseudorandom noise might very well have good properties, but it ain't crypto-quality unless you can _prove_ it has good properties, and I wouldn't know where to begin to do that.

Cheers,

Phil Hobbs

Reply to
Phil Hobbs

I can confirm that. I developed a method of measuring the error rate of hard disk drives back in the 80's. It saved everyone huge amounts of time by plotting the distribution of data transitions inside the data separator windows. This fits a Gaussian curve, which is a parabola when plotted on a log/lin graph.

I once plotted the curve down to some ridiculous error rate. It took over a month to get down to maybe 1e-13 or so, and the data points fit exactly on the plotted parabola. I terminated the test since the next data point would have taken a year and we would most certainly have a power failure in that time.

John von Neumann was a bit more colorful. He joked, "Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin."

Terry Ritter has done some good work on characterizing semiconductor noise sources and showing how bad they are using autocorrelation.

Here's the start page:

formatting link

Noise Measurements of Zener, Bipolar, LED, Diodes, IC's:

formatting link

Here's Analyzing Noise Generators:

"Any electronics experimenter can build a noise source. Unfortunately, building a good noise source is harder than it looks. Correctly using such a source is harder still."

formatting link

Next: Statistical and Graphic Views of Noise

formatting link

His home page with all kinds of cypher stuff:

formatting link

A vast number of links:

formatting link

There are all kinds of ways of analyzing the output of random number generators. Vladimir would be a better source, so I'll stop here and let him take over.

Regards,

Mike Monett

Reply to
Mike Monett

usually 7 pips are used :)

any reason why you need to use thermal noise? one easy way to do these it to runt the counter real fast while the go button is pressed, basically an elkectronic "wheel of fortune"

Bye. Jasen

Reply to
jasen

As long as the counter enable is pure hardware and completely separate from any "counted" process, like an instruction in a microcontroller loop ("is the button still pressed?").

Reply to
Richard Henry

The resistor isn't obligatory, but it seems like it would be a lot like what you did with the zener, except with a resistor. What was the noise source in the zener, if not thermal?

Reply to
Greg Hansen

What does it take to amplify shot noise? Say a very small voltage across a resistor or diode. Can you just put a 741 on that, or does that need something more specialized?

Reply to
Greg Hansen

Oh, neat! References! I'll have to check them. Got anything with a title like "A simple, high-quality random generator circuit"?

For my purposes, if it matters, I wouldn't just assume that each number is equally likely. I'd run the statistics on it-- frequency of each number, and correlation between successive numbers. So I don't see a reason to be exceptionally worried about the raw distribution. I just want something that is "close enough" to ideal and that, in principle, cannot be predicted. And that can't be manipulated, as some claim dice can be.

Reply to
Greg Hansen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.