Randomness is hard - to produce and to understand. If you thought that the archetype of randomness was the iconic coin toss, some researchers have some important news for you - the coin tends to land on the same side it started with. How can this be and what can be done about it?

Finding something that is truly physically random is a tough exercise, but the act of tossing a coin has long been thought to be 100% random for the simple reason that there seems to be no way that a coin toss can be influenced in any way to give a particular outcome. Although the actual coin toss is clearly 100% deterministic, there is no quantum mechanics involved and the coin obeys Newton's laws of motion, the final state is sensitive to the actual initial conditions and these are generally unknown anyway. It is randomness that originates from an almost chaotic process in the absence of complete information.

*ICMA Photos*

Coin tossing is such a trusted source of randomness that the recent paper lists some interesting outcomes:

*"... in 1903 a coin flip was used to determine which of the Wright brothers would attempt the first flight; in 1959, a coin flip decided who would get the last plane seat for the tour of rock star Buddy Holly (which crashed and left no survivors); in 1968, a coin flip determined the winner of the European Championship semi-final soccer match between Italy and the Soviet Union (an event which Italy went on to win); in 2003, a coin toss decided which of two companies would be awarded a public project in Toronto; and in 2004 and 2013, a coin flip was used to break the tie in local political elections in the Philippines."*

And before you speculate about biased coins, there is lots of evidence that such a thing doesn't exist as long as the coin isn't bent or allowed to spin after it lands. The weight distribution of a coin doesn't influence which side it lands on.

We use similar randomness in our pseudo random number generators - deterministic systems that are sensitive to initial conditions and ignorant of the seed value used to start the process. Even our physical random number generators are based on the same idea, although the deterministic system is usually something like noise in an electrical component or a count of a fast running timer. If you get involved in such things you quickly discover that ensuring good randomness is very, very difficult. But surely the same cannot be true of coin tossing?

Of course not, so move along people nothing to see here.

Not so fast ... In 2007 the paper:

*Diaconis P, Holmes S, Montgomery R. " Dynamical bias in the coin toss", SIAM Review 2007; 49(2): 211–235*

proposed an unlikely mechanism operating in a simple coin toss. It seems the the flipping mechanism contains a bias. If you flip the coin in the usual way so that it spins, the spin induces an off-axis precession which tends to keep the initial up side face up in the air. As a result a coin has a bigger chance of landing with the a face up that corresponds to the face up at the initial toss. Analysis and experiment suggests that on average a same coin toss has a probability of 0.51 compared to a difference of 0.49.

Now we have additional evidence that this is true. A group of 48 people tossed coins of 46 different currencies and denominations, obtaining a total number of 350,757 coin flips and:

*the data feature 178,078 same-side landings from 350,757 tosses, Pr(same side) = 0.508, 95% CI [0.506, 0.509] (see Table 1 for a by-person summary), which is remarkably close to Diaconis’s prediction of (approximately) 51%.*

*In addition, the data show no trace of a heads-tails bias. Specifically, we obtained 175,420 heads out of 350,757 tosses, Pr(heads) = 0.500, 95% CI [0.498, 0.502] (see Table 2 in the methods section for a by-coin summary).*

So a coin toss is random unless you can set its intial starting configuration and know the call you want to realize. If your oponent calls heads and you want to win then start with tails facing up. What is also interesting is:

*Moreover, the data revealed a substantial degree of between-people variability in same-side bias, some people appear to have little or no same-side bias, whereas others do display a same-side bias, albeit to a varying degree. This variability is consistent with Diaconis’ model, in which the same-side bias originates from off-axis rotations (i.e., precession or wobbliness), which can reasonably be assumed to vary between people.*

So be careful who you gamble with.

Is the difference practically important?

*If you bet a dollar on the outcome of a coin toss (i.e., paying 1 dollar to enter, and winning either 0 or 2 dollars depending on the outcome) and repeat the bet 1,000 times, knowing the starting position of the coin toss would earn you 19 dollars on average. This is more than the casino advantage for 6 deck blackjack against an optimal-strategy player, where the casino would make 5 dollars on a comparable bet, but less than the casino advantage for single-zero roulette, where the casino would make 27 dollars on average .*

So what can we do about it? The obvious thing to do is to improve the balance of heads or tails. To do this, hide the intial configuration before calling an outcome or apply a simple transformation, called "von Neumann whitening" after its inventor. a technique I introduce in my latest book, *Programming the ESP32 in MicroPython*

If you have a bitstream with unequal probabilities of a one or a zero you can transform it to a 0 on a change from 0 to 1 and a 1 on a change from 1 to 0 and discard bits pairs of bits that are equal, i.e. 00 and 11. There are obviously as many up-going edges as there are down-going edges so the number of ones and zeros is the same.

What can you do to ensure a fair coin toss?

Treat a single toss as not "head or tails" but "same or different". These have slightly different probabilities, so apply von Neumann whitening and toss twice, discarding repeated same or repeated different instances, using the final same or different as the head or tail outcome.

The analysis is easy. If the probability of same is p and the probability of different is q=(1-p) then the probablitiy of:

same twice is p*p

different twice is q*q

same followed by different p*q

different followed by same q*p

and so if you keep tossing and stop when you get a same followed by different or different followed by same you have equal probabilities.

I'm not at all sure the whitening method will catch on - imagine trying to explain or implement it on a sports field...

Randomness is hard.

**Harry Fairhead**has a hardware background having worked with microprocessors and electronics in general, for many years. He is the author of,*Programming the Raspberry Pi Pico/W in C*, and*Programming the Raspberry Pi Pico/W in MicroPython*His latest book, is*Master the Raspberry Pi Pico in C: WiFi with lwIP & mbedtls.**Programming the ESP32 in MicroPython.*

#### More Information

**VIDEO: How random is a coin toss? - Numberphile**

Fair coins tend to land on the same side they started: Evidence from 350,757 Flips

#### Related Articles

**VIDEO: Coin flipping probability | Probability and Statistics | Khan Academy**

Inside Random Numbers

The Monte Carlo method

How not to shuffle - the Knuth Fisher-Yates algorithm

The Programmer's Guide to Chaos

ERNIE - A Random Number Generator

The Monty Hall Problem

John Von Neumann The Great Polymath

Kolmogorov Complexity

Canada's RAND Immigration Lottery Not Random!

Random Means Random - The Green Card Fiasco

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

#### Comments

**VIDEO: Probability Distribution for Random Variables | 2 Coins Probability Distribution**

or email your comment to: [email protected]

<ASIN:187196282X>

<ASIN:1871962811>

<ASIN:1871962684>

<ASIN:1871962692>

Author: Christine Martin

Last Updated: 1704152761

Views: 1109

Rating: 4.5 / 5 (115 voted)

Reviews: 94% of readers found this page helpful

Name: Christine Martin

Birthday: 1953-09-01

Address: 199 Rose Cliff Apt. 541, North Karenstad, TX 50438

Phone: +4025305367302421

Job: Network Administrator

Hobby: Arduino, Camping, Archery, Skateboarding, Sewing, Aquarium Keeping, Robotics

Introduction: My name is Christine Martin, I am a Precious, unguarded, rich, capable, Gifted, tenacious, resolved person who loves writing and wants to share my knowledge and understanding with you.