[Math] Coin Flipping Probability Mass Function & Expectation

expectationprobability

A coin comes up Heads with probability p and Tails with probability 1-p. Flipping this coin four times the sequence of outcomes is noted and then rewritten by replacing Heads with 0s and Tails with 1s. This way, a sequence of length four that consists of 0s and 1s is obtained.

Let X be the number that has this sequence as its base 2 expansion. Example: if the flips are H, T, T, H then the 0-1 sequence is 0110 and X = 0x8 + 1×4 + 1×2 + 0x1 = 6. Plot the probability mass function of X and determine its expectation E(X) in case:

1) p = $\frac{1}{2}$ i.e. the coin is fair

2) p = $\frac{1}{3}$ i.e. the coin is biased

PROGRESS:

Honestly I have made none because I do not know how to generate the probability mass function and getting a bit confused by the "base 2 expansion" bit. Once I have the mass function I think I can calculate the expectation from there. Thanks for any help!

Best Answer

The point is very simple: The order of flips matters.

You are given four random variables $X_i, i = 1,2,3,4$, where each one stands for a toss of a coin, in ascending order of indices. You have to calculate the following quantity : $X = 8X_1 + 4X_2 + 2X_3 + X_4$,right? This can have values between $0$ and $15$.

For the first part: Now, how is $X_i$? Well, it is $0$ or $1$ with probability half, so the expectation value is just $E[X] = 8 \times 0.5 + 4 \times 0.5 + 2 \times 0.5+1 \times 0.5 = 7.5$, because the expectation of one toss is $0 \times 0.5 +1 \times 0.5 = 0.5$.

How about the mass function? Well, each number, from $0$ to $15$, has an equal probability of coming, because each one has a unique representation in binary, and the probability of heads and tails are the same. Hence, it is just $P(i) = \frac{1}{16}$, for $i=0,1, \ldots, 15$ (there are sixteen possibilities in total, each occurs equally probably).

In the second question: The expectation of each $X_i$ now is $0 \times \frac 13 + 1\times \frac 23 = \frac 23$, so then $E[X] = (8+4+2+1) \times\frac 23 = 10$.

Finally, here, every number has a unique binary expansion, but this time the heads and tails don't have the same probability, so the mass function changes, and it changes as follows: given the number of $1$s in the expansion, so many tails are required for the number to come, which happens with higher probability. So more the ones, more the probability.

So, we look at the binary expansions:

1) The numbers having no $1$s is only zero.

2) The numbers having precisely one $1$ are $2$,$4$,$8$,$1$.

3) The numbers having precisely two $1$s are $3$,$5$,$6$,$9$,$10$,$12$.

4) The numbers having precisely three ones are $7$,$11$,$13$,$14$.

5) Only $15$ has four ones.

Hence, we can write down the probabilities as follows:

1) For zero, the probability is $\frac{1}{3^4} = \frac{1}{81}$.

2) For the numbers with only one $1$, the probability is $\frac{1}{3^3} \times \frac{2}{3} = \frac{2}{81}$.

3) For the numbers having $2$ ones, the probability is $\frac{1}{3^2} \times \frac{2^2}{3^2} = \frac{4}{81}$.

4) For the numbers with three $1$s, the probability is $\frac{1}{3} \times \frac{2^3}{3^3} = \frac{8}{81}$.

5) For the numbers with all $1$s, the probability is $\frac{2^4}{3^4} = \frac{16}{81}$.

Hence, this is the probability distribution function in the end: $$ P(x) = \begin{cases} \frac{1}{81} & x=0 \\ \frac{2}{81} & x=1,2,4,8 \\ \frac{4}{81} & x= 3,5,6,9,10,12 \\ \frac{8}{81} & x = 7,11,13,14 \\ \frac{16}{81} & x = 15 \\ \end{cases} $$