You're It!

Are Digital Draws Really Fair? Random Numbers and Bias Explained

Published:

When an online draw goes against you, "this must be rigged" comes to mind fairly quickly. Computers only follow fixed calculations, so how can they pick at random at all? Here are three places where a draw is made fair, or quietly isn't.

Where do random numbers come from?

Many programs use a pseudo-random generator, which repeats a complex calculation from one starting value to produce numbers that look random. That is fine for everyday use, but anyone who knows the starting value and the method can predict the next number.

A cryptographic random generator instead draws on hard-to-predict values collected by the operating system, and it is designed so past output doesn't reveal future output. Browsers expose one through crypto.getRandomValues in the Web Crypto API, and draws on this site use it.

Good randomness can still be skewed

Good random numbers aren't the end of the story. The most common mistake is the remainder operation. Suppose you pick one of three people by taking a number from 0 to 255 and dividing by 3. Since 256 doesn't divide evenly by 3, person zero has 86 winning values while the other two have 85. It's a tiny difference, but a real one.

The fix is simple. Accept only the range that divides evenly and redraw anything above it. In this example you would use 0 to 254 and redraw on 255. This site picks whole numbers the same way.

The shuffling trap

Shuffling has a similar pitfall. Going through a list and swapping each item with any position looks fine, but it makes some orders more likely. With only three people there are 27 equally likely swap sequences and 6 possible orders, and because 27 doesn't divide evenly by 6, the result can't be even.

The widely used Fisher-Yates shuffle works from the end of the list and only swaps within the part that isn't settled yet. Every order then comes out with exactly the same probability.

The show versus the result

A wheel creeping past a boundary is not the moment the result is decided. Most games choose the outcome when you press the button and then animate toward it, so there's no trick to the wheel's speed or starting position.

There are exceptions. Spinning Darts calculates the result from where the dart lands, and Pinball Drop uses the outcome of its physics simulation as it is.

Is a streak suspicious?

With four people spinning a wheel, the chance that the same person gets caught twice in a row is a full one in four. People tend to expect random results to be evenly mixed, but true randomness naturally produces clusters, because one result doesn't affect the next. Do offer your sympathy to the friend on a losing streak.

Games to try with this guide

Worth a read