You have coins
. For each k, coin
is biased so that, when tossed, it has probability
of falling heads. If the n coins are tossed, what is the probability that number of heads is odd? Express the answer as a rational function of n ?
Let
denote the desired probability. Then
, and for
, By conditioning on
coin’s outcome, we can see that

Using above recurrence we get
. Now it is easy to guess that
. It is easy to verify this guess using Mathematical Induction.
Now, let us see alternative way to derive the same result using Generating Functions.
If
is a discrete random variable taking values on some subset of the non-negative integers,{0,1,….,n}, then the probability-generating function of X is defined as :

where symbol
denotes the Expectation of Random Variable.
If
is a sequence of independent ( not necessarily identically distributed ) random variables, and
, then the probability-generating function of
is given by
.
The last equality follows from the fact that the expectation of product of independent random variables is equal to the product of expectation of individual random variables.
Let the probability of heads on
be donted by
. So
. Let 
Let
denote the indicator random variable, which takes on value 1 if
falls on heads, takes value 0 otherwise
P.G.F of
is 
Let
denote the number of heads in the n coin tosses. So 
P.G.F of
is 
The probability of getting exactly m heads is equal to the coefficient of
in the generating fucntion, that is
.
Since the coin tosses are independent,

Notice that

and

The required probability is 
Hence

It is easy to interpret the result of substituting 1 for z in terms of probability : it is the probability of Sample Space , which is 1. The result of substituting -1 for z, is the Difference between probability of getting Even number of heads and probability of getting Odd number of heads ( Generating functions actually helped in calculating this difference easily ). The difference is equal to
. In retrospect, we can see why this is so. If we expand this product we see that each +ve term in the expansion correspond to the probability of some sample point which has even number of heads in it, and each -ve term in the expansion correspond to probability of some sample point which has Odd number of heads in it. Hence the sum of +ve terms is equal to probability of getting Even number of heads, and the sum of -ve terms is equal to probability of getting Odd number of heads.