|
Page 1 of 2
Random?
Most things that are unpredictable we call “random” but it is important to notice that this isn’t the same thing as truly random behaviour. You could say that true randomness isn’t really a part of everyday life.
For example, if you throw a coin up in the air you might say that which side it comes down is “random”. However, if you think a little more carefully what you are saying is that the physics of the process are simply not within your powers to predict. You could imagine that if you measured the forces applied to the coin and knew its mass and shape then application of Newton’s laws of motion would make the outcome predictable. OK there would be problems such as air currents and so on in making the calculation but you can see that by putting enough effort into the problem, in principle if not in practice, you can reduce something that is random to something that is predictable.
This is how it nearly always is and unless you are a quantum physicist you really should think in terms of randomness meaning “unpredictable”. Although it isn’t really important from a computing point of view most people do like to know if there is such a thing true randomness.
The answer to this question is hinted at in an earlier comment. Only quantum physics seems to provide us with examples of true randomness because part of its dogma is that quantum processes are in principle unpredictable. If you accept the truth of quantum mechanics then the best you can do is to give probabilities for what is going to happen. When the objects involved get larger than these probabilities move closer to one and zero and we have the approximation to the world we live in where things can be certain and predictable.
Computers and randomness
So moving back to computers and randomness what sort of things can we make a computer do that makes it look unpredictable? Notice that even here we have to be weaker than simply saying “to make a computer behave randomly”. The reason is that even though “random” mostly means the same as “unpredictable” there is a big difference between the unpredictability of tossing a coin and what you can make a computer do.
The difference is, of course, the program. When you toss a coin you are giving in to vague mechanics to produce something that is unpredictable. When you program a computer everything is precisely and entirely predicable. The fact that a program makes a computer do what it does means that, unlike the coin, you always have a mechanism for predicting what it is going to do i.e. the program it is running always determines exactly what is going to happened and reading it through reveals all.
For this reason the sort of unpredictability that a computer can produce is usually called “pseudo randomness” – or false randomness. In practice the difference between true randomness, randomness, and “pseudo randomness” doesn’t matter but you still have to be clear in your mind about which one you are discussing, particularly when criticising a situation that is claimed “random”.

One way to get real random numbers - an early random number generator used radioactive decay to generate a random signal.
Before we go much further you should try to construct something that will make a PC appear random. If you know how to program then you might well be thinking of using the function that generates random numbers in a programming language you know called RND or something similar, but this is simply cheating. Some other poor programmer had to solve the problem to give you the RND function and to see how hard a task it was you have to avoid simply using it!
One thought that often occurs is why not mimic the coin toss by simply getting together a jumble of programming instructions to produce a “random program”. After all if you run a random program who knows what it does! This reasoning is only partly correct because in practice you can be fairly sure of knowing what a random program does – nothing!
Mostly the random arrangements of instructions don’t do anything useful at all and this isn’t a practical way of creating randomness.
A second thought might be to try and copy the toss of a coin by sampling something that is rapidly changing – i.e. mimicking the spin of the coin. For example, every PC has a timer which counts in thousands of a second how long it has been switched on. Why not simply read the last two digits of the time in thousands of a second and use these as a random event – i.e. a random number in the range 00 to 99.
This does indeed provide you with a random number, after all how long the machine has been on measured in milliseconds changes far too quickly for you to be able to predict the value of the last two digits. However, when you start looking too carefully at this method you discover that it has some problems.
For example, if you sample it to get a random number 23 say then if you sample it soon after you are going to get 24. Unless the sampling rate is very small compared to the counting rate you are going to get “random” numbers that tend to increase. This might not matter too much for some applications and indeed the PC timer plays a role in generating random numbers but not quite the one you might expect.
<ASIN:1400063515>
<ASIN:1852334177>
<ASIN:1400067936>
|