# N tosses of a coin ,what is the probability that number of heads are even?

We have a coin with probability of head is p and probability for tail is (1-p). We toss the coin N times, what is the probability that the number of tosses that show head is even?

What I've tried is to sum over all even k's (k= 0,2,4,...) and to sum up the probability that the number of heads is k. Is there a way to elinimate the sum and to give a closed formula?

• certainly this will be of help – Tyler Nov 3 '13 at 19:45
• Hint: $\displaystyle (x+y)^n + (x-y)^n = 2\sum_{k=0}^{n/2} \binom{n}{2k}x^{n-2k}y^{2k}$ – Dilip Sarwate Nov 3 '13 at 19:48
• @DilipSarwate Thanks. Where can I find this formula? I didn't see it at the wiki article on the Binomial theorem – Shmoopy Nov 3 '13 at 19:53
• Write out the right sides of the following two equations using the binomial theorem: \begin{align}(x+y)^n &= x^n + nx^{n-1}y + \cdots \\(x-y)^n &= x^n - nx^{n-1}y + \cdots \end{align} and see if something develops when you add the equations. – Dilip Sarwate Nov 3 '13 at 19:57
• Possible duplicate of If nine coins are tossed, what is the probability that the number of heads is even? – Yanior Weg Jun 27 '19 at 20:12

Let $a_N$ be the probability that $N$ Bernoulli trials result in an even number of successes. This occurs if an initial failure is followed by an even number of successes, or an initial success is followed by an odd number of successes. Therefore $a_0=1$ and for $N\geq 1$ $$a_N=q a_{N-1}+p(1-a_{N-1}).$$ Multiplying by $s^N$ and adding over $N$ we see that the generating function satisfies $$H(s)=1+qsH(s)+ps(1-s)^{-1}-psH(s)$$ or $$2H(s)=[1-s]^{-1}+[1-(q-p)s]^{-1}.$$ Expanding the right hand side using geometric series we find that the coefficients satisfy $$a_N={1\over 2}+{(q-p)^N\over 2}.$$
• A small note, $q$ is defined as $q=1-p$ (i.e. the probability of failure) – deps_stats Oct 25 '17 at 23:37
• What boggles me about it is how would you define the sample space in this problem to get the complement probability that is used in the solution. If $A_n$ is the event of having an even number of heads after n tosses, it is well defined in a sample space of n tosses. But then what is the event $A_{n-1}^c$ in the same sample space? It should include the event of odd number of heads after $n-1$ tosses, but also even number after n tosses, since it's in the complement. How would you define the sample space for both $A_n$ and $A_{n-1}$? – Paul Oct 14 '19 at 13:31