May 2

RNG Random Number Generators

Gambling

0  comments

Have you ever wondered what happens behind the scenes when you play online slots and other games of chance?  How exactly does a computer spin a roulette wheel or pick bingo balls?  The short answer is random numbers.  The long answer is a journey through the worlds of mathematics, quantum mechanics and philosophy, but let’s keep it simple!

Computers are predictable.  No, don’t laugh.  Deep down, under all those crashing programs and unexpected error messages, they just want to do the same thing over and over again.  Tell them to add one and one and they will always say two.  So how can a computer pretend to shuffle a deck of cards and come up with different hands every time?

Pick a number.  Let’s pick 7 as it’s lucky.  Multiply by 31, add 123, then rub out everything except the tens and units.  That, as I’m sure you have just worked out, gives 40.  Now do it all again starting with 40 instead of 7 and we end up with 63.  Doing this over and over again gives the list 7, 40, 63, 76, 79, 72, 55, 28, 91, and so on until the calculator batteries go flat.  We could use the numbers 1 to 52 to represent the 52 cards in a deck and throw away the rest.

What we’ve just done is generate the pseudo-random sequence

X0 = 7,   Xn = (31 Xn-1 + 123) mod 100

Clever eh?  This is actually one of the simplest ways of generating random numbers.  It might be good enough for some purposes but there’s one slight problem: it’s not random!  After a while, the sequence repeats exactly, just like a deck of cards that’s only shuffled at the start of the game and then just recycled.

People have spent many years inventing better random number generators.  This is not just to stop you cheating at roulette but also because making random numbers less predictable is crucial to many kinds of computer security.  Sometimes though, it’s simpler just to find something truly random, measure it and use the measurements as our random numbers.  Such hardware random number generators might measure things like the noise you hear when your radio isn’t tuned in or the time between key-presses on your computer keyboard.  This takes us into the realms of subatomic particle physics and the deterministic nature of the universe but I’ll save that for another day.

Further reading:
http://www.random.org/randomness/
http://en.wikipedia.org/wiki/Random_number_generator
http://foldoc.org/?random+number

About the author 

David Gale

David Gale is a gambling writer and journalist, covering all aspects of gambling: from gaming history to games strategy and responsible gambling topics, focusing on how to gamble safely and with maximum enjoyment.

You may also like

Those were the days: Slingo, Zynga and Facebook

Why You Should Play Rainbow Riches Slots

What Happens to Your Brain When You Win at the Casino?

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Subscribe to our newsletter now!