Is there an algorithm that can generate random numbers? Of course, the question is if there is such an algorithm which is deterministic. But a deterministic algorithm always provides deterministic results. So the question is – can we provide an algorithm with a random seed, in such a way that it will provide an infinite range of random numbers in an unpredictable way? The answer is obviously no. I can prove it!
First, I already showed that it’s not possible to select a random number in the range 0 to 1, if all the possible numbers have the same probability. Since we can treat an infinite series of random bits (either 0 or 1 with the same probability) as a real number between 0 and 1, then it seems that I already proved it. But to clarify it, I only proved that we can’t tell such a selection, I didn’t prove we can’t make one. But if we can define an algorithm that can create such a series, this is equivalent to defining the number or telling it. Therefore, there exist series of 0 and 1 which no deterministic algorithm can create!
Second, if we consider the number of bits necessary to write down both the algorithm and the random seed, we can define this as n. Then there are only 2n number of possibilities for strings of length n. And therefore, the number of different series we can produce with n bits (both the algorithm and the random seed) is not more than 2n. And for any known algorithm, only the number of bits in the random seed counts. For n bits, this algorithm will create no more than 2n different series. This means that theoretically, if we see the beginning of a series given by this algorithm (the first m bits for some m) then we can tell the rest.
But, we can still create series of numbers (or series of bits) which look as random to us – that is, we can’t tell any order in it, we can’t compress it and so on. I like to define it with the word entropy (taken from physics). I was about to define it, but it seems that there is already a good definition in Wikipedia. In other words – although we can’t generate a true random series, we can generate a series which will look random to any observer. That’s good enough.
I like to consider irrational numbers, like the square root of 2 for example, as a series of pseudo-random bits (when written in the binary form). That is – there is no order in it, we can’t compress it and so on. While I will not try to prove it, I think it’s quite obvious. If you don’t believe me, then I’d like to give you a challenge – prove that the google (10100) bit is either 0 or 1 (that is, either prove it’s 0, or prove it’s 1). I bet you can’t do it. And if for some strange reason you do succeed, try google! (the factorial of google) or googleplex (10google).
If you need a way to calculate the first n digits of the binary form of the square root of 2, here’s a simple algorithm. Of course, you need to implement it or use a software which lets each number have n bits of precision (after the dot).
1. let x be any seed number, such as 1.
2. let x2 = 2/x.
3. let x be (x+x2)/2.
4. If the first n digits of x2 and x are not equal, go to step 2.
5. The result is x.
It can be proved that this algorithm converges very quickly – in about O(log2(n)) iterations. That is, to calculate the google first bits will take less than 500 iterations of this loop (or actually, something around 332, which is the log of google in base 2). But the problem is, in order to make calculations of n precision you will need to store n bits, and the calculation itself will take about O(n) steps in machine language. So the total amount of time to calculate the first n bits of the square root of 2 is about O(n*log2(n)). I doubt you will ever get to implement it for google!
Therefore, I can claim that there exists an integer n, which for every bit of the square root of 2 beyond the nth bit, we can’t prove that it is 0 and we can’t prove that it is 1. It’s not that we can’t calculate it – we can calculate it in theory, but it will take infinite time (that is, the calculation will never end during our life time). This is also related to the halting problem – the algorithm to calculate the first n bits of the square root of 2 will halt for every small n, but for big values of n it will never halt. Of course you can claim that in theory it will halt, but in reality there exists an integer n for which it will never halt. Even for relatively small numbers it will not halt – such as google, and you need only 333 bits to represent google in the binary form.
Since we don’t know if the googleth bit of the square root of 2 (and any bit beyond it) is 0 or 1, we can define its probability to be 50% for either 0 or 1. I’m not going to prove this mathematically, but for me it makes sense. Although every bit is either definitely 0 or definitely 1 (according to mathematical logic), for us it has 50%/50% probability to be either 0 or 1. This is like the uncertainty principle in quantum physics – we don’t know something, and we know we don’t know it, but we can define its probability for every possible value. The probability is not inherent in the value itself, but it is our knowledge of it. Although the value of every bit of the square root of 2 is deterministic, we can look at it in a probabilistic way.