TITLE: If nine coins are tossed, what is the probability that the number of heads is even?
QUESTION [53 upvotes]: If nine coins are tossed, what is the probability that the number of heads is even?
So there can either be 0 heads, 2 heads, 4 heads, 6 heads, or 8 heads.
We have $n = 9$ trials, find the probability of each $k$ for $k = 0, 2, 4, 6, 8$
$n = 9, k = 0$
$$\binom{9}{0}\bigg(\frac{1}{2}\bigg)^0\bigg(\frac{1}{2}\bigg)^{9}$$ 
$n = 9, k = 2$
$$\binom{9}{2}\bigg(\frac{1}{2}\bigg)^2\bigg(\frac{1}{2}\bigg)^{7}$$ 
$n = 9, k = 4$
$$\binom{9}{4}\bigg(\frac{1}{2}\bigg)^4\bigg(\frac{1}{2}\bigg)^{5}$$
$n = 9, k = 6$
$$\binom{9}{6}\bigg(\frac{1}{2}\bigg)^6\bigg(\frac{1}{2}\bigg)^{3}$$
$n = 9, k = 8$
$$\binom{9}{8}\bigg(\frac{1}{2}\bigg)^8\bigg(\frac{1}{2}\bigg)^{1}$$
Add all of these up: 
$$=.64$$ so there's a 64% chance of probability?

REPLY [3 votes]: A useful way to think about this problem, especially for the case of generally unfair coins, is in terms of a recurrence.  Let $p$ be the probability that the coin flips heads, and let $q_n$ be the probability, after $n$ flips, that the number of flips is even.  So, in particular, $q_0 = 1$: Before the coin has been flipped at all (after $0$ flips, in other words), the probability that the number of heads is even equals $1$.
We can write a recurrence for $q_{n+1}$ in terms of $q_n$ as follows:

If the parity (the even-or-oddness of the heads) was even after $n$ flips, which happens with probability $q_n$, then it stays even with probability $1-p$.
If the parity was odd after $n$ flips, which happens with probability $1-q_n$, then it turns even with probability $p$.

(We assume, as is typical in these problems, i.i.d. flips.)  With these two observations in mind, we get
$$
q_{n+1} = q_n(1-p) + (1-q_n)p
$$
which we can rewrite as
$$
q_{n+1} = p + (1-2p)q_n
$$
If this recurrence has a limit $q_n \to q$, then we can put
$$
q = p+(1-2p)q
$$
$$
2pq = p
$$
from which we get that either $p = 0$ (in which case, clearly, $q_n = 1$ for all $q$—if you only flip tails, then the parity of heads will always be even), or $q = 1/2$; that is, the limiting probability of even parity is $1/2$ (and the same for odd parity, too, obviously).  If there is no limit, it will be because $p = 1$, and we continually alternate between even and odd parity.  I do not show this, but it is not difficult.
It is also not difficult to show that the recurrence has the solution
$$
q_n = \frac12 + \frac12(1-2p)^n
$$
and this lays out why the symmetry arguments work out well for fair coins: $(1-2p)^n = 0$ for all $n > 0$, leaving us with just $q_n = 1/2$.

It may help to see this recurrence in the form of a Markov chain with two states:

Since the transition probabilities from one state to the other are equal ($p = p$), the state probabilities at equilibrium (if such exists) must also be equal, and therefore both equal to $1/2$.