Steven R. Dunbar
Department of Mathematics
203 Avery Hall
University of Nebraska-Lincoln
Lincoln, NE 68588-0130
Probability Theory and Stochastic Processes
Steven R. Dunbar
Distinguishing A Biased Coin From a Fair Coin
Mathematically Mature: may contain mathematics beyond calculus with proofs.
You are presented with two coins: one is fair and the other has a chance of coming up heads. Unfortunately, you don’t know which is which. How many ﬂips would you need to perform in parallel on the two coins to give yourself a chance of correctly identifying the biased coin?
The following problem appeared in the FiveThirtyEight.com weekly Riddler puzzle column on September 29, 2017:
On the table in front of you are two coins. They look and feel identical, but you know one of them has been doctored. The fair coin comes up heads half the time while the doctored coin comes up heads 60 percent of the time. How many ﬂips you must ﬂip both coins at once, one with each hand would you need to give yourself a 95 percent chance of correctly identifying the doctored coin?
Extra credit: What if, instead of 60 percent, the doctored coin came up heads some percent of the time? How does that aﬀect the speed with which you can correctly detect it?
This problem appeared in a paper “What’s Past is Not Prologue” by James White, Jeﬀ Rosenbluth, and Victor Haghani. They in turn were inspired by the problem posed in a paper “Good and bad properties of the Kelly criterion” by MacLean, Thorp and Ziemba.
Solving this problem requires some interpretation and computation.
In any ﬁxed number of simultaneous ﬂips, there is always a chance that the fair coin will have more heads than the biased coin. But the Weak Law of Large Numbers says that the probability that the biased coin will have a majority of heads increases to as the number of ﬂips increases. One way to determine which is the biased coin is to choose the coin which has a majority of heads. The authors White, Rosenbluth, and Haghani want to calculate how many ﬂips of coins, one biased and one fair, we must observe in order to be conﬁdent that the coin with more heads is the biased coin.
Since each coin has a binomial distribution and the coins are assumed independent, the joint probability mass distribution after ﬂips is the product of the individual binomial probability mass distributions. Denote by the probability of heads for the fair coin and heads for the biased in ﬂips. Use for the probability of heads of the biased coin and for the probability of heads for the fair coin. Then
Then summing over values where gives the probability that the biased coin has more heads than the fair coin in ﬂips
There is no closed formula to evaluate this sum so calculation is necessary. First create two vectors of length with the binomial distribution on to with probability for the fair coin and with probability for the biased coin. Then using the outer product of these two vectors create the bivariate binomial distribution for the two coins. This will be an matrix. The element in row and column is the product of the binomial probability of heads for the fair coin and the binomial probability of heads for the biased coin. The sum is over column indices strictly greater than the row indices. To create the sum, set the lower triangular part of the matrix and the diagonal of the matrix to and use the sum command to sum all entries of the matrix. This seems to be eﬃcient, even for values of up to . To ﬁnd the minimal value of for which this probability is greater than use binary search over a reasonable interval.
It might seem possible to use a bivariate normal approximation of the bivariate binomial distribution to calculate the probability. While there is such an approximation, the double integration of the bivariate normal with a non-zero covariance would be over a region of the form . There is no direct way with R to calculate the integral over a region of this form, so it is actually easier to calculate with the bivariate binomial distribution.
The result is that it takes ﬂips of the two coins for the probability to be greater than for the biased coin to have more heads than the fair coin.
The same analysis for various probabilities of heads for the biased coin and for values , and of certainty is in Figure 1. The number of ﬂips required decreases as the bias increases, as expected. The number of ﬂips required also decreases as the certainty decreases.
Assume that the biased coin is in the left hand. Let be the result of left-hand coin ﬂip , knowing it is biased so with probability , with probability . Let be the result of right-hand coin ﬂip , knowing it is fair so with probability , with probability . Let . This is a trinomial random variable with with probability , with probability , with probability .
Consider the statistics of ,
Let be the sample mean. Then is distributed on to by increments of for a total of points with
Thus, the distribution of clusters around with standard deviation . The goal is ﬁnd a number of ﬂips such that the probability that is closer to than with probability . This would be enough to clearly distinguish the mean from the possible alternative which is coming from the biased coin in the right hand.
By the Chebyshev inequality
Here the values for the Chebyshev inequality are
Taking , if is large enough then . Solving for , gives however Chebyshev is notoriously weak, so this is more than actually necessary.
Expressing the precise distribution of analytically is diﬃcult. So instead, use a numerical calculation of the distribution. To numerically calculate the distribution of the sample mean , use the R package distr and speciﬁcally the function convpow which takes the -fold convolution power of a distribution to create the distribution of the -fold sum of a random variable. Note that mathematically the support of the distribution of, for instance , would be from to , with points. However, the actual calculated distribution support of, for instance, , is points from to . The reason is that points with probability less than are ignored, so are not included in this domain. So use match(-10, (support(D100))) to ﬁnd the index of (namely ). This turns out to be index . So summing the distribution over indices from to gives the probability that the random variable is bigger than . Recall that is the mean value if the biased coin is in the right hand. Searching for a value of large enough that the probability exceeds gives the required number of ﬂips.
Using this algorithm, the necessary number of ﬂips to distinguish a biased coin with a probability of heads from a fair coin with a certainty level of is . The same analysis for various probabilities of heads for the biased coin and for values , and of certainty is in Figure 2. The number of ﬂips required decreases as the bias increases as expected. The number of ﬂips required also decreases as the certainty decreases as expected.
There is an interesting observation for values of and all values of certainty. According to Figure 2, it only takes ﬂips of the coins to identify the biased coin for these parameters. That is because the probability distribution of is in Table 1. The probability that is greater than is .
The two values of required are strikingly diﬀerent. Why is that so?
The calculation of the probabilities uses fundamentally the same information, as the diagram in Figure 3 for the case illustrates. The array of dots represents the support of the bivariate binomial distribution as a matrix, with rows from to for the number of heads from the fair coin and columns to for number of heads for the biased coin.
The probability that the majority of ﬂips is from the biased coin is the sum of the probabilities in the strict upper triangle of the support of the bivariate distribution. The shaded portion of Figure 3 shows this domain.
The multinomial probability distribution on to of the -fold sum is the sum of the probabilities along diagonals of the bivariate binomial distribution as indicated by the red arrows. In the case the biased coin has so the mean of , the probability of the event
is the sum of the probabilities in the strict upper triangle and additionally the main diagonal and the subdiagonals from to . Thus the total probability is larger for the statistical calculation and for a given level of certainty to exceed the certainty the required number of ﬂips is less.
The choice of decision criterion is motivated by the application. The original problem posed in FiveThirtyEight.com was drawn from a white paper by James White, Jeﬀ Rosenbluth, and Victor Haghani from Elm Partners Investing. In turn their example is motivated by a paper “Good and bad properties of the Kelly criterion” by McLean, Thorp and Ziemba. The question is a simpliﬁed and idealized version of an investment question about how much evidence is required to select a higher performing investment, modeled by a biased coin, from a lower performing investment with just an even chance at making a proﬁt, modeled by a fair coin. In that case, the certainty of a majority of gains is a reasonable choice of criterion. However, if the question is merely to identify the biased coin, then it makes sense to use the Central Limit Theorem to distinguish the mean given that the biased coin is in the left hand from the mean given that the biased coin is in the right hand. That is, the probability distribution of the sample mean “condenses” around the expected value of the diﬀerence with smaller variance as the number of ﬂips increases. Some of the probability may even come from cases where there are a more heads produced by the fair coin but the preponderance of evidence indicates the biased coin. Thus it takes a smaller number of ﬂips to conﬁdently identify the biased coin.
The deﬁnition of biased coin is from Wikipedia. The problem appeared in the FiveThirtyEight.com weekly Riddler puzzle column on September 29, 2017. This ﬁrst subsection with the majority solution is adapted from a white paper “What’s Past is Not Prologue” by James White, Jeﬀ Rosenbluth, and Victor Haghani from Elm Partners Investing. In turn, their example is motivated by a paper “Good and bad properties of the Kelly criterion” by McLean, Thorp and Ziemba. The second subsection with the statistical solution is original.
R script for majority binary search..
R script for statistical binary search..
 Leonard C. MacLean, Edward O. Thorp, and William T. Ziemba. Long-term capital growth: the good and bad properties of the Kelly and fractional Kelly capital growth criteria. Quantitative Finance, 10(7):681–687, 2010.
I check all the information on each page for correctness and typographical errors. Nevertheless, some errors may occur and I would be grateful if you would alert me to such errors. I make every reasonable eﬀort to present current and accurate information for public use, however I do not guarantee the accuracy or timeliness of information on this website. Your use of the information from this website is strictly voluntary and at your risk.
I have checked the links to external sites for usefulness. Links to external websites are provided as a convenience. I do not endorse, control, monitor, or guarantee the information contained in any external website. I don’t guarantee that the links are active at all times. Use the links here with the same caution as you would all information on the Internet. This website reﬂects the thoughts, interests and opinions of its author. They do not explicitly represent oﬃcial positions or policies of my employer.
Information on this website is subject to change without notice.
Steve Dunbar’s Home Page, http://www.math.unl.edu/~sdunbar1
Email to Steve Dunbar, sdunbar1 at unl dot edu
Last modiﬁed: Processed from LATEX source on December 14, 2017