Eyeball Test to Identify An Unfair Coin (or A False Record)

The results of two coins which are tossed 200 times respectively are:



Which is the unfair one (or a false record)? In the animation below, x1 denotes the first coin, while x2 is the record of the second coin. The plot in the middle is 1000 simulations from the Binomial distribution with p = 0.5 and size = 1. An equivalent question to the hypothesis test is, which plot looks like the simulation more? Of course we should give a visual definition to "similarity" before comparison. Imagine if you are going to perform a test numerically, which statistic will you choose? For me, at least three options are available:

  1. Number of heads (or tails): if too many/few heads (or tails) show up, the coin might be unfair
  2. Maximum run length, i.e. maximum number of successive 0's or 1's (e.g. for coin A, there are ten 0's); don't take it for granted that ten successive 0's is a rare event in 200 tosses -- the probability is not 0.5^10; if the run length is too long or too short, we may consider the coin as unfair
  3. Number of changes from 0 to 1 or 1 to 0: if the coin changes too frequently from one side to the other side, it can be regarded as unusual too

Accordingly, we can present these statistics in a visual way. Plot the observed sequences and a simulated sequence as a reference, and compare observed graphs with the reference to see which one is unusual:

  1. How many points are in the top (equivalently, bottom)
  2. Length of the longest horizontal segment
  3. Density of vertical lines

Now watch the Flash animation below (Fullscreen Flash animation):

Yihui Xie /
Published under (CC) BY-NC-SA in categories featured  r language  tagged with Binomial distribution  Coin  Hypothesis Test  run  Simulation