Q:

Poisson distribution - doubt in a book proof

Suppose we 
flip a coin a random number $N$ of times, where
$$P(N = n) = (e^{-r})\frac{r^n}{n!}\qquad n = 0,1,2,\ldots$$
that is, $N$ has a Poisson distribution. The flips are independent, and the probability of seeing heads is equal to p. Hence if we know that $N = n$, the number of heads is simply the number of heads in $n$ coin flips with success probability $p$. We write $X$
for the total number of heads, and $Y$ for the total number of tails, so $X +Y = N$.
Question: Why is $$P(X=x) = \sum_{n\geq x} P(X=x|N=n)P(N=n)\quad ?$$
Also, how does one calculate this sum?

A:

You can add an intermediate step as follows:
$\begin{align}
P[X = x] &= \sum_{n=1}^\infty P[X = x, N = n]\\
         &= \sum_{n=1}^\infty P[X = x | N = n] P[N = n],
\end{align}$
where we used Bayes' formula in the second step. Of course all terms with $n < x$ are zero because if $n < x$, it's impossible to get $x$ heads after $n$ flips.
As to how to calculate the sum, you should fill in the probabilities and see what you can do. Note that P[X = x | N = n] is the same as the probability of flipping $n$ coins and getting $x$ heads, which you can calculate.

A:

What you describe is called the law of total probabilities.   The proof goes like this
$$P(X = x) = \sum_{n=0}^\infty P(X = x\; {\rm and}\; N=n)
= \sum_{n= 0}^\infty P(X = x|N=n)P(N=n)$$
Now $X$ is a sum of $n$ binomials, so if $n < x$ we cannot have $X = x$; in this case $P(X = x | N = n)  = 0$.  
Since we have independent trials, $P(X = x | N = n) = {n\choose x}p^x(1-p)^{n-x}$
giving the summation.  
Now it is time to compute the summation.  We have
$$P(X=x) = \sum_{n=x}^\infty P(X=x|N=n)P(N=n) = 
\sum_{n=x}^\infty {n\choose x}p^x(1-p)^{n-x}{r^ne^{-r}\over n!}.$$
Regrouping and cleaning up we have
$$P(X=x) = e^{-r}\sum_{n=x}^\infty {1\over x!(n-x)!}(rp)^x(r - rp)^{n-x} $$
Now reindex to obtain
$$P(X=x) = e^{-r}\sum_{n=0}^\infty {1\over n!x!} (rp)^x(r-rp)^n = 
{(rp)^xe^{-r}\over x!}\sum_{n=0}^\infty {(r-rp)^n\over n!}= {(rp)^xe^{-r}\over x!} e^{r-rp} = {(rp)^xe^{-rp}\over x!}.$$
What you get is distrubuted Poisson(rp).

