One of the claims that I saw on social media in the aftermath of the recent EU referendum here in the UK was that the result (52% to 48%) was so close that it was little different from tossing a coin.

Without getting bogged down in the politics of that referendum, or the various campaigns that led up to it; I want to consider whether this claim holds any water. How similar to millions people each tossing a coin and voting accordingly was the result?

According to the BBC, there were 17,410,742 votes to leave and 16,141,241 votes to remain, giving a total of 33,551,983 votes. If we were to make each of these people toss a coin and count up the results, the ratio of heads/tails or remains/leaves could be anywhere between all heads and all tails. However, we would expect the counts to be about equal if the coins were all fair. Of course, any ratio is possible, but if we were to run the coin tossing game repeatedly, we would expect to mean ratio to converge on 1:1. How likely would a 52:48 ratio be?

The leave side got a share of the vote equal to 0.51891842. Therefore, their absolute deviation from the expectation (the mean, or 0.5) is 0.01891842. The difference between the two counts is 1,269,501. Would we expect to see a deviation of this magnitude in a coin tossing competition?

Being a computer programmer rather than a mathematician, I’m going to look at this using a simple program.

WriteLine("heads, tails, flips, heads share"); var runs = 1000; // Taken from http://www.bbc.co.uk/news/politics/eu_referendum/results var flips = 33551983; var randomNumberGenerator = new Random(); for (var run = 0; run < runs; run++) { var heads = 0; for (var coinToss = 0; coinToss 0) { heads++; } } WriteLine($"{heads}, {flips - heads}, {flips}, {(0.0 + heads) / flips}"); }

This program simulates 1,000 coin tossing competitions with 33,551,983 players and writes the counts as comma separated values.

Putting the output into Excel, the largest deviation was 0.000275081 (or a difference between counts of 18,459) and the smallest was 1.49022E-08 (which was 16,775,992 heads and 16,775,991 tails. This happened twice in 1,000 runs!) The largest difference between heads and tails was 69 times smaller than the result from the referendum.

Plotting the shares in decreasing order, we see how quickly larger deviations fall off:

Putting the deviations into bins and counting the competitions by deviation from the expectation, we see that smaller deviations are more common:

Whatever else we might say about the result, we cannot seriously claim that the result was random.

The full program can be found here:

The Excel file can be found here:

http://www.reversing-entropy.com/wp-content/uploads/2016/09/EuRef.xlsx

## One thought on “Was the EU Referendum Random?”