Is there a true random number generator?
7 02 Sep 2015 14:50 by u/crankypants15
In programming class we built random number generators. When you gave it a number, a "seed", it would produce quasi-random numbers. The problem was, if the seed was the same, the series of numbers that would be output would be exactly the same each time.
Is there a true random number generator that does not rely on an external seed? Is there a RNG where you put in the same seed you get different series of numbers?
EDIT: I agree current RNGs are fine for games, generating landscapes, etc. But then I got to thinking: "What IS truly random anyway? And how would one go about making a series of numbers truly random?"
11 comments
7 u/insert_name 02 Sep 2015 16:31
Well, I can only offer a Physics POV. From a laws-of-nature standpoint, nobody knows if true randomness exists. We simply don't know yet. I have a feeling we will never ever know. It probably requires us to know everything about nature and reality and everything else. I mean, quantum fluctuations (which seem completely random to us atm) could be as a result of chaotic motions of things we don't yet know of.
Basically, the Universe is either deterministic or truly random, or in other words, pseudorandom or random.
But I think all this drivel isn't what you wanted so sorry, I'll see myself out.
5 u/Devilbiter 02 Sep 2015 15:55
If there were a RNG that gave different answers for the same seed, why bother seeding at all? ;)
Some alternative methods are to use long strings of values of things that are constantly changing for seeds. Epoch time time is good for that, since it's got 10 digits and changes every second. More robust methods measure the voltage in a resistor, temperature or some component of weather to the umpteenth digit to generate a seed. Those last few digits change so easily you'll "rarely" have a repeat.
If you really want to dive down that rabbit hole, consider getting your hands on a copy of Numerical Recipes.
Note: I'm not an expert, but I've run a few Monte Carlos.
2 u/Craftkorb 02 Sep 2015 18:12
First off, you're referring to PRNGs, Pseudo-random number generators. Generally they're treated the same, but in your case, I'd like to make this distinction.
Then, for what would we need "real" RNGs, or at least pretty much unpredictable PRNGs? You're correct in that games and all that get by fine with pretty simplistic ones. But there is a large area where you want to have really really good random numbers, and that's everywhere you some sort of cryptography going on. So, for example, TLS connections is such case, as when you do online banking, you really don't want someone else to "listen in". Having good random numbers for stuff like this is highly necessary. Another prominent example would be harddrive encryption using tools like LUKS/LVM on Linux (No idea about other tools). This one requires a large chunk of random data (Probably 4KiB), which uses it as key for the encrypted files (etc.). Why it does this would go too far though :)
Next up, security. As I've mentioned above, we have legit cases where we need good random numbers to offer a secure operation. I want you to take a moment and ask yourself "what would happen if someone would replace a really good RNG with a really bad (= predictable) RNG?". Think about the last paragraph. ... ... Okay. So, the answer is, it's really bad because if you have predictable numbers coming out of a RNG, then all cryptography and security you build on top is completely worthless. In fact, this is a real attack vector used by spy agencies (among others) to tap into connections or access encrypted files. You could write a whole book about this too ..
Now, how could we acquire real random numbers? This is pure physics, and I slept during these classes. What I do know however is that you need a source which is unpredictable. Hopefully, it stays that way for a long time, until scientists figured out how it works. There is for example random.org, who basically aimed a antenna at something in space, and use that incoming noise as random data. Which, as it's unpredictable, pretty good in itself, but see the next paragraph. Then, there are also tons of hardware RNGs, which rely on physic phenomena yielding unpredictable results. Wikipedia has a decent article on that. But, how do computers without specific hardware can acquire random data? This is a hard issue, but in general, this is a feature provided by the Operating Systems Kernel. To do that, it uses somewhat random events as input, and then 'generates' sequences of random data as output. Those events can be inputs (USB devices, e.g. mouse movement, button presses, ..), file I/O (Reading/writing data in sector X on device Y, ...). So, if you were ever asked by an application to now randomly type stuff or move your mouse around, that's why :) But also, things can go wrong, I still remember when Debian completely broke their kernel RNG. But also read the other sections, I don't want to hate on Debian.
At the end, I want to ask you if you trust those services. Let's say you need real random numbers for cryptography, and choose to use a remote service like random.org as source. Well, how are you sure that these numbers are really random, and not just look random to you? Complex issue, which if you think about it, is not really solvable in itself. In general though, if you need really random data, use a hardware RNG, and just hope that it's pretty random.
2 u/kruhft 03 Sep 2015 14:27
A lot of processors have random number generation hardware based on the quantum properties of silicon:
https://en.wikipedia.org/wiki/Hardware_random_number_generator
1 u/CaptainRex 02 Sep 2015 18:39
On Linux, at least, /dev/random uses entropy information from hardware devices to produce "almost" truly random sequences.
https://en.wikipedia.org/wiki//dev/random
1 u/President-Sanders 02 Sep 2015 20:06
There's some that use atmospheric noise / radiation and other sources - but if you know the sources you might even be able to guess at what they were using.
1 u/thrus 02 Sep 2015 20:36
Seems like the best way to get more random is to use layers. Say a RNG based on the time (86400 seconds in the day so many seeds) have it output a 32 digit number, use this combined with the exact weather conditions somewhere to generate a 256 number, us this new seed to generate your number. You now have the number of loops needed for the 32 digit number * the loops for the 256 * the number for the last RNG. To even get the same result you have to be at the same time and weather conditions for a loop. Swap to Epoch time and use three locations weather conditions plus a cause that forces it to re-gather the data all the way each number and you have a very low chance of it getting the same input to try and loop the numbers. You could even use any number of PRNGs with differing loop cycles if you don't want to go outside of the program for data sources. Processing power vs how random becomes the only real limiting factor.
0 u/MarianOnEarth 22 Sep 2015 06:42
No. Because we are working on deterministic machins, so a RNG is always going to be in some defined state. This means that when we ask the computer for a random number you have to also tell the computer how to get the random number (if you put x in a function you will always get y).
Now, you could use properties that are inherently more random like and algorithm based on the temperature of the room, ambient light, or decay of an isotope. Unfortunately as the dataset gets larger you'll find that there is a probability field of quantities that are measured. Some x's will then be more common than others. It is just the nature of nature.
So far there is no way for us to develop a RNG that is nondeterministic; it may be possible if we can develop a system that uses superposition (the switch is on, off, both on and off, and neither on nor off all at the same time), but when we measure a particle in superposition "the wave function collapses" and the particle is no long in superposition. The particle becomes deterministic and predictable by a probability field. Here's a Numberphile episode on the subject.
THAT BEING SAID: please keep thinking about this problem. Even if you don't find the solution, you'll find something interesting along the way.