Follow up: A flips an **unfair** coin 11 times, B 10 times: what is the probability A gets more heads

probability

For the first 10 times of A, he has the same expected number of heads as B. So if the 11th flip of A results in H, he gets more head than B, so the answer is $p_H$.

  • this answer is wrong based on the following numerical result:

from matplotlib import pyplot as plt
import numpy as np
from scipy.special import comb as C

def game(p, n1=11, n2=10):
    q = 1-p
    x = sum([ 
        C(n1, a) * p**a * q**(n1-a) * sum([ 
            C(n2, b) * p**b * q**(n2-b)
            for b in range(0, a-1 + 1)
        ])
        for a in range(0, n1 + 1)
    ])
    return x 

p = np.linspace(0, 1, 100)
x = [game(pi) for pi in p]

plt.plot(p, x)
plt.xlabel('unfair coin: p(head)')
plt.ylabel('probability A gets more head')
plt.axhline(0.5)
plt.axvline(0.5)
plt.show()

Best Answer

There's no closed formula in general. But except in extreme cases, a Normal approximation will work well.

("Extreme" cases occur when one or more of the expected counts of heads or tails for either player is tiny. "Tiny" depends on the accuracy you need, but as we will see below, even when one of these expected counts is as low as $3,$ the approximation can be good to more than two decimal places.)

As is usual, this approximation is obtained by matching moments: the mean of $A-B$ is $\mu = 11 p_A - 10 p_B$ while the variance of $A-B$ is $\sigma^2 = 11 p_A(1-p_A) + 10 p_B(1-p_B).$ To approximate the answer, we will use a Normally distributed variable $X$ with the same two moments.

As indicated by this plot of the probability mass function (PMF) of $(A,B)$ (drawn on top of an image of its approximation afforded by $X$), a good way to represent the event "A wins outright" is with the set where $X \ge 1/2$ (rather than, say, $X \gt 0$), corresponding to all points below and to the right of the white diagonal line, because this does a better job of capturing the correct probability. (Using $1/2$ rather than $0$ is often called a "continuity correction," referring to replacing a discrete calculation involving the PMF with a calculation based on the continuous random variable $X.$)

Figure

Thus, in terms of the standard Normal distribution function $\Phi,$ a suitable approximate answer is

$$\Pr(X \ge 1/2) = \Phi\left(\frac{\mu - 1/2}{\sigma}\right).$$

In the figure $p_A = 0.7$ and $p_B = 0.4.$ The fully accurate answer, obtained by summing the PMF where $a \gt b,$ is $0.927\ldots,$ while the Normal approximation gives $0.929\ldots.$

When $p_A=p_B=1/2,$ the symmetry of the problem as noted in your previous question continues to hold for the Normal approximation (provided the continuity correction is used!) and, since $\mu - 1/2 = 0,$ both methods give the correct value of $0.5 = 1/2$ exactly.

This R code performs the calculations.

#
# Specify the problem.
#
B <- (A <- 11) - 1
p.A <- 7/10
p.B <- 4/10
#
# Compute the bivariate PMF.
#
X <- within(expand.grid(a = 0:A, b = 0:B), 
            Probability <- dbinom(a, A, p.A) * dbinom(b, B, p.B))
#
# Normal approximation.
#
m <- diff(c(p.B, p.A) * c(B, A))
s <- sqrt(sum(c(p.A, p.B) * (1 - c(p.A, p.B)) * c(A, B)))
#
# Compare the results.
#
c(Accurate = sum(subset(X, a > b)$Probability),
  Approximate = pnorm((m - 1/2) / s))