IN-DEPTH Truly, deeply, randomly
TRULY, DEEPLY, RANDOMLY
Random numbers are essential for so much of everyday life but they’re not as easy to generate as we might think. Mike Bedford takes us on a journey through the murky world of randomness to see how it’s done.
Our subject here is random numbers, and how to generate them. And to be honest, we wouldn’t blame you if you think that sounds as enthralling as watching paint dry.
What’s more, if we were to quote the definition “a random number is a number chosen as if by chance from some specified distribution such that selection of a large set of these numbers reproduces the underlying distribution” – whatever that means – we fear that might reinforce your view. We have to admit, though, that we presented that particular mathematics definition just to be mischievous, and we promise to do our very best to keep you entertained.
The fact is that generating random numbers isn’t as straightforward as we might hope or expect. In this article we’ll delve into a wide range of technologies which, you might be relieved to hear, aren’t all concerned with virtually impenetrable maths.
If you want to learn when a random number isn’t a random number, what an entropy pool is and why Linux maintains one, how some Intel processors can generate true random numbers using special hardware, or why we should be interested in random numbers in the first place? In that case, just read on. But if you think this expose will help you break the bank at Monte Carlo, though, we suggest you think again.
Before getting to the heart of generating random numbers, let’s pick up the question of why we need them. After all, unless there are real-world applications, any study of random numbers would be little more than a pure academic exercise. And to many of us, that wouldn’t be especially engrossing, to put it mildly.
So, how are random numbers used? If you’re a coder, you’ll be aware that most programming languages offer a random number function, and you’ll probably have made use of that functionality. You might have used it in a video game, for example, to ensure that gameplay differs each time it’s launched. Indeed, games are a key application of random numbers, perhaps for shuffling a deck of cards before they’re dealt, for creating a new random layout for a maze, or deciding the shape of new blocks in Tetris. If we expand on the word gaming to include gambling, we come to another application of random numbers. Here the stakes are greater – quite literally – which places greater demands on just how random the numbers are. Traditionally, such unpredictability would be provided by a roulette wheel or a well-shuffled deck of cards, but the onset of online gambling changed all that. So although the user might see an on-screen representation of the conventional paraphernalia of a casino, all this is driven by a stream of electronically derived random numbers.