#29 Understanding Random
If I ask you to come up with a random number, what is the first thing that you do? What number did you select? Was it rooted in something…
This is post #29 of my #365 day series.
Press enter or click to view image in full size
If I ask you to come up with a random number, what is the first thing that you do? What number did you select? Was it rooted in something that you saw recently or is it just your go to random number? Is it as random as you can get? Now ponder, how does a computer do it? It doesn’t nearly have the creativity nor the compute power that you have. Your brain is a supercomputer. A regular computer is a finite logic system. Why does this matter? Random is a very important concept to understand in computing and cryptography (see: https://www.cloudflare.com/learning/ssl/lava-lamp-encryption/). It’s what keeps your banking details safe and the internet generally safe. Random is not purely a measure of probability, it is a measure of unpredictability as well. What does that mean?
Let’s take for example a list of numbers:
1, 2, 3, 4, 5, 6, 7, 8, 9
Now, if I were to come up with a random order of the above list, it might look something like this:
2, 1, 5, 4, 6, 9, 3, 7, 8
Is it random? Sort of. Unpredictable? Hardly. First off, as I go from left to right, the probability of knowing the next number is somewhat dependent on how good I am at guessing the first few numbers. So, you can think of it this way, if I can guess 2 as the first number, then the remaining 8 numbers have a higher likelihood of being right. For every index (the position of the number) that I get right, it drastically increases the likelihood that I will get the next number right.
2 | ? ? ? ? ? ? ? ? ? (the next few options can only be 1 and then 3 through 9)
as I get more and more right, you can see how the search space (the amount of possible answers) gets smaller.
2 1 | ? ? ? ? ? ? ? ? (the next few options can only be 3 through 9)
Now, ordering aside, is the combination unpredictable? Well, first we have to define predictability. If something is predictable, then that means that there is less than an infinite probability of being able to solve for the problem, to get the right answer. Put another way, the lower the probability I could guess the right answer, the more unpredictable a system is. The above list has a finite number of constraints, so the unfortunate thing is that the system is VERY predictable and very NOT unpredictable (double negative was intentional to get the point across.).
So how does a computer come up with a random number?
One typical way that this is done is to base it off of some function of current time and then perform a series of calculations on such number to simulate a random number. This is why we refer to computer based random numbers as pseudo random numbers. This also means that given a sufficient data set, we can find a pattern and work backwards to derive or predict the next random number. This seems like an impossible task and back when our compute power wasn’t so powerful it might have been a difficult task, but these days where storage is cheap and parallel computing (think GPUs) it’s all very doable.