23 October 2012

How To #8: Random Number Generators

Since my new G/T project is about generating truly random numbers, I thought I might do a post about the subject. First I'll talk about why generating random numbers is so difficult, and then I'll talk about the different generators that produce them.
Generating random numbers is easy. Making them truly random, however, that takes a little bit more work. For example, if you want to generate random numbers with an Arduino, you just write a program that plants a "seed" and then generates a random value from an open pin. That works, and it's really efficient for generating a lot of random numbers, but, say, you need to test the aftermath of a nuclear bomb. That would need truly random numbers, or numbers that you cannot predict. If you're generating  random numbers from any computer, those numbers are called pseudo random numbers, or numbers that, if you knew the program or formula to, you could regenerate that exact same sequence of numbers. So, if you're testing a nuke, you need truly random numbers. If you're needing random numbers for predicting a business's future, then I guess you would use pseudo random numbers.
The random number generator inside Arduino is called a pseudo random number generator, or PRNG. That generator produces numbers that are pseudo random. The second generator is called a truly random number generator, or TRNG. That generates truly random numbers. The third one I just learned about today in my G/T class, and that's called a quantum random number generator, or QRNG. This type of generator produces truly random numbers from the quantum world. They put sensors in a vacuum with nothing in it, and the sensors are so sensitive, they can actually sense the particles coming and going in the quantum world. Since the particles are there one millionth of a second and not there one millionth of a second later, the results are truly random.
One other way to generate truly random numbers is to connect a geiger counter's output to an Arduino, have the Arduino read the value, and then send it over to the Serial Monitor or an LCD.
Now, it's time to generate some random numbers.

No comments: