This is the third of four posts on the mathematical approach known as the Monte Carlo method, following 'Where did those neutrons go'.
As we saw in the previous post, the Monte Carlo method depends on having a stream of random numbers. Unfortunately, randomness is not easy to generate. Ask someone for a series of random choices between 1 and 10 and they will not do well - for example, there won't be sufficient repeated values for a true random stream. In another extract from my book Dice World, let's take a look at what appears to be random whether we use a spreadsheet or a more sophisticated source:
In Excel I have two random number functions, RAND, which gives me a random value between 0 and 1 (I just got 0.61012053) and RANDBETWEEN to choose a random number in a range. (My value for between 1 and 10 came out as 4.) Job done. Unfortunately, what Excel gives us is not random numbers, but pseudo-random numbers. Numbers that are random enough for, say, making a prize draw, but that aren’t good enough if you want a good long sequence of numbers that are truly random.
That is because the pseudo-random number generator is not genuinely picking between the options with equal probabilities, nor is any value in a sequence of numbers it generates totally independent of what came before. That has to be the case or we can’t calculate the random number using some sort of computer algorithm. A spreadsheet’s pseudo-random generator usually starts with a ‘seed’, an initial value which is often taken from the computer’s clock, and then repeatedly carries out a mathematical operation, typically multiplying the previous value by a constant, adding another constant and then finding the remainder when dividing by a third constant. So, for instance, a crude pseudo-random number generator would be something like:
New value = (1,366 × Previous Value + 150,899) modulo 714,025
where ‘modulo’ is the fancy term for ‘take the remainder when you divide it by ...’ The output of the pseudo-random number generator wanders off away from the seed value and can be reasonably convincing in appearance, but it will always produce the same values given the same seed, and can’t match a true random number generator for effectiveness of results. Although my Excel RANDBETWEEN function can produce two repeated values, because it is rounding a wide range of real number values to get to the same figure, the pseudo-random generator will still always be limited because it can never produce the same exact value twice in a row or it would get locked into repeating that value over and over.
Those who want to be more careful about their randomness look for a better way of producing their outputs. Most large lotteries rely on machines with a series of balls in them, which are randomised by stirring them up before balls are drawn. This is not the best way of getting a random number by any means. It’s still a pseudo-random number generator. The chances of the balls being drawn in a perfectly random fashion are very low. But in this particular example, visibility is more important than perfection. It is considered more important for players to see the draw happening than it is to approach the perfection of true randomness.
This isn’t the case for all lotteries, though. In the UK, for instance, we have an unusual kind of lottery known as premium bonds. These are government bonds that allow the buyer to have a little flutter, instead of providing a predictable return for all purchasers, as is traditional with bonds. Most premium bonds will return no ‘interest’ (though unlike a lottery ticket they can be cashed in to get the initial stake back). But 1 in 24,000 of the £1 units wins a prize in each draw*. Some bonds will produce this cash return, which can vary from a few pounds to £1 million.
To make the draw fair, the people behind premium bonds were among the first in using electronic random number generation with a device known as ERNIE, a contraction of Electronic Random Number Indicator Equipment. This device was introduced in 1957, designed by Tommy Flowers, the man behind the world’s first electronic programmable computer, the Colossus, at the World War II code-cracking centre, Bletchley Park.
ERNIE worked by using the noise in the signal produced by a series of valves (vacuum tubes). All elec- tronic devices produce a degree of noise due to thermal variations in the materials, interference and other effects. Although not truly random, because the outcome could in principle be predicted if you had all the available data, no one has access to that data and the effect is sufficiently chaotic that it is impossible to have any idea what will come next. Because of this, it is a safer way to generate pseudo-random numbers than a software-based approach. More recent variants of ERNIE (they are on to Mark IV) make use of thermal noise in transistors.
True random values can be produced using quantum effects, and true random generators are now available to plug into electronic devices if required. For example, if you have a radioactive source, where atoms occasionally spontaneously emit part of their nucleus, you can predict how often an atom will undergo such a decay on average, but the decay of a specific atom is truly random: it is not just impractical to predict but is impossible because there literally is no cause. The modern-day ERNIE could be based on such a system, but the approach taken is equally good in terms of being unpredictable and is easier to produce.
With random numbers fed in, we will look at more modern uses of the Monte Carlo method in the final post.
* Since Dice World was written, the chances of winning with a premium bond increased to 1 in 21,000.
Image from Unsplash by Dylan Nolte
See all of Brian's online articles or subscribe to a weekly digest for free here
Comments
Post a Comment