Library · The Fiddler: Solutions · Chapter 135

Can You Flip the Coins Exactly as You’d Expect?

Revised Report an error

Flip three fair coins. There are four possible outcomes: three heads (with probability 1/81/8), two heads (3/83/8), one head (3/83/8) and no heads (1/81/8).

Now flip the three coins eight times. What is the probability that you get exactly one occurrence of three heads, three of two heads, three of one head and one of no heads, in any order?

The Fiddler, Zach Wissner-Gross, November 17, 2023(original post)

The official solution appeared in the post of December 1, 2023 and gives 36⋅5⋅7/219≈4.873^6 \cdot 5 \cdot 7/2^{19} \approx 4.87 percent for the main puzzle and the pattern (4,3,1,0)(4, 3, 1, 0), at about 17.517.5 percent, for the Extra Credit. Both agree with the answers below.

Solution

Count the ways first, then price each one. Write the eight rounds as a string of results such as 3 2 2 2 1 1 1 0,3\,2\,2\,2\,1\,1\,1\,0 , where each symbol is the number of heads in that round. Because the rounds are independent, any one string with one 33, three 22s, three 11s and one 00 has probability (18)1(38)3(38)3(18)1  =  3688.\left(\tfrac18\right)^{1} \left(\tfrac38\right)^{3} \left(\tfrac38\right)^{3} \left(\tfrac18\right)^{1} \;=\; \frac{3^6}{8^8}. How many such strings are there? Arrange eight symbols in 8!8! orders, then divide out the reorderings of the three equal 22s and of the three equal 11s, which do not produce new strings: 8!1! 3! 3! 1!  =  1120.\frac{8!}{1!\,3!\,3!\,1!} \;=\; 1120 . Every one of these strings has the same probability, so  P  =  1120⋅3688  =  36⋅5⋅7219  =  25515524288  ≈  4.87%. \boxed{\ P \;=\; 1120 \cdot \frac{3^6}{8^8} \;=\; \frac{3^6 \cdot 5 \cdot 7}{2^{19}} \;=\; \frac{25515}{524288} \;\approx\; 4.87\%. \ } Small as it is, this is the single most likely set of counts. The data matching the probabilities exactly is the best guess, but there are so many near misses that the bull’s-eye is rarely hit.

The computation

The program builds the chances for one round by listing all eight equally likely results of three coins. It then runs through all 48=65,5364^8 = 65{,}536 possible sequences of eight rounds, multiplies the chances along each, and adds up the sequences whose counts are one, three, three and one. Fractions keep it exact.

from fractions import Fraction
from itertools import product
from collections import Counter

# one round: count heads over the 8 equally likely coin triples
heads = Counter(sum(c) for c in product((0, 1), repeat=3))
p = {h: Fraction(n, 8) for h, n in heads.items()}

target = {3: 1, 2: 3, 1: 3, 0: 1}
total = Fraction(0)
pattern = Counter()             # for the Extra Credit below
for seq in product(range(4), repeat=8):
    pr = Fraction(1)
    for h in seq:
        pr *= p[h]
    counts = Counter(seq)
    if all(counts[h] == n for h, n in target.items()):
        total += pr
    key = tuple(sorted((counts[h] for h in range(4)),
                       reverse=True))
    pattern[key] += pr
print("main:", total, float(total))

It prints

main: 25515/524288 0.04866600036621094

Extra Credit

Again flip three coins eight times. Among the four outcomes, the most frequent occurs aa times, the next bb times, then cc, then dd, so a+b+c+d=8a + b + c + d = 8 and a≥b≥c≥da \ge b \ge c \ge d (ties allowed). Which ordered quadruple (a,b,c,d)(a, b, c, d) is most likely?

Solution

The quadruple forgets which outcome had which count. So its probability is a sum over every way of handing the four counts to the four outcomes. Each hand-out is priced just as in the main puzzle: if the two likely outcomes (two heads and one head, each 3/83/8) receive mm of the eight rounds between them, the hand-out has probability 8!a! b! c! d!⋅3m88,\frac{8!}{a!\,b!\,c!\,d!} \cdot \frac{3^{m}}{8^8}, because each of the mm rounds contributes a factor 33 and every round contributes 1/81/8.

There are only 1515 quadruples, and two forces pull against each other. Counts near the expected 1,3,3,11, 3, 3, 1 make each hand-out likely. Four different counts allow the most hand-outs, 4!=244! = 24, while repeated counts allow fewer. Work out the two strongest candidates.

For (4,3,1,0)(4, 3, 1, 0) the multinomial factor is 8!/(4! 3! 1! 0!)=2808!/(4!\,3!\,1!\,0!) = 280. All 2424 hand-outs are different. The likely pair of outcomes receives some two of the counts, in either order, and the other pair receives the remaining two, in either order, so each choice of pair appears 2×2=42 \times 2 = 4 times: 4(34+3+34+1+34+0+33+1+33+0+31+0)=4⋅2622=10488,\begin{align*} &4\left(3^{4+3} + 3^{4+1} + 3^{4+0} + 3^{3+1} + 3^{3+0} + 3^{1+0}\right) \\ &\qquad= 4 \cdot 2622 = 10488 , \end{align*} and the probability is 280⋅10488/88=45885/262144≈17.50280 \cdot 10488/8^8 = 45885/262144 \approx 17.50 percent.

For (3,2,2,1)(3, 2, 2, 1) the multinomial factor is 16801680 and there are 1212 hand-outs. The likely pair takes {3,2}\{3, 2\} in 44 hand-outs, {3,1}\{3, 1\} in 22, {2,2}\{2, 2\} in 22 and {2,1}\{2, 1\} in 44, giving 4⋅35+2⋅34+2⋅34+4⋅33=14044 \cdot 3^5 + 2 \cdot 3^4 + 2 \cdot 3^4 + 4 \cdot 3^3 = 1404 and a probability of 1680⋅1404/88≈14.061680 \cdot 1404/8^8 \approx 14.06 percent.

The same arithmetic for every quadruple gives the full table:

quadruple hand-outs chance quadruple hand-outs chance
(4,3,1,0)(4,3,1,0) 2424 17.50%17.50\% (5,3,0,0)(5,3,0,0) 1212 4.74%4.74\%
(3,2,2,1)(3,2,2,1) 1212 14.06%14.06\% (6,1,1,0)(6,1,1,0) 1212 3.42%3.42\%
(5,2,1,0)(5,2,1,0) 2424 12.81%12.81\% (5,1,1,1)(5,1,1,1) 44 2.96%2.96\%
(4,2,1,1)(4,2,1,1) 1212 12.80%12.80\% (4,4,0,0)(4,4,0,0) 66 2.87%2.87\%
(3,3,2,0)(3,3,2,0) 1212 8.53%8.53\% (6,2,0,0)(6,2,0,0) 1212 2.68%2.68\%
(4,2,2,0)(4,2,2,0) 1212 8.20%8.20\% (2,2,2,2)(2,2,2,2) 11 1.22%1.22\%
(3,3,1,1)(3,3,1,1) 66 7.09%7.09\% (7,1,0,0)(7,1,0,0) 1212 1.04%1.04\%
(8,0,0,0)(8,0,0,0) 44 0.08%0.08\%

The pattern of the main puzzle, (3,3,1,1)(3, 3, 1, 1), is only seventh: its one great hand-out cannot make up for having just six. The winner is  (a,b,c,d)=(4,3,1,0), with probability 45885262144≈17.5%. \boxed{\ (a, b, c, d) = (4, 3, 1, 0), \text{ with probability } \frac{45885}{262144} \approx 17.5\%. \ }

The computation

The loop in The computation above already filed every sequence under its sorted counts. Print the most likely quadruples.

for key, pr in pattern.most_common(3):
    print(key, pr, f"{float(pr):.4f}")

It prints

(4, 3, 1, 0) 45885/262144 0.1750
(3, 2, 2, 1) 36855/262144 0.1406
(5, 2, 1, 0) 33579/262144 0.1281
Report an error on this page

Reports are stored by Netlify. See the privacy note.