Exercise Problem 53, Chapter 4, Blitzstein and Hwang

57 Views Asked by At

I am self-learning undergraduate calculus-based probability. I'd like someone to verify if my approach and final solution to the below problem is correct. I am not so sure, about the variance, so any hints/clues would be nice.

A coin with probability $p$ of heads is flipped $4$ times. Let $X$ be the number of occurrences of $HH$ (for example $THHT$ has $1$ occurrence and $HHHH$ has $3$ occurrences). Find $E(X)$ and $Var(X)$.

Solution. (My attempt)

Let $A_j$ be the event that an $HH$ occurs at the positions $(j-1,j)$ and $I_{A_j}$ be the indicator function of $A_j$.

We have,

\begin{align*} P(A_j) = p^2, \quad E(I_{A_j}) = p^2, \quad Var(I_{A_j})=p^2(1-p^2) \end{align*}

Let $X$ be the total number of occurrences of the string $HH$. Then,

\begin{align*} X &= \sum_{j=2}^{n} I_{A_j}\\ E(x) &= (n-1)p^2 \end{align*}

If $n = 4$, $E(X) = 3p^2$.


The random variables $I_{A_j}$ and $I_{A_{j+1}}$ are identically distributed, but not independent. The random variables $I_{A_j},I_{A_k}$ with $k > j+1$ are identically distributed independent random variables.

Case I. $k > j + 1$.

\begin{align*} E(I_{A_j} I_{A_k}) &= E(I_{A_j}) E(I_{A_k}) \\ Cov(I_{A_j},I_{A_k}) &= E(I_{A_j} I_{A_k}) - E(I_{A_j}) E(I_{A_k})\\ &= 0 \end{align*}

Case II. $k = j + 1$.

The random variable $I_{A_j}\cdot I_{A_{j+1}} = 1$, if and only if both $I_{A_j} = 1$ and $I_{A_{j+1}} = 1$. The joint probability of the event $\{I_{A_j} = 1, I_{A_{j+1}} = 1\}$ is given by,

\begin{align*} P\{I_{A_j} = 1, I_{A_{j+1}} = 1\} &= P\{I_{A_{j+1}} = 1|I_{A_j} = 1\} \cdot P \{ I_{A_j} = 1\}\\ &=p \cdot p^2 \\ &= p^3 \end{align*}

Thus, the covariance of these random variables is given by,

\begin{align*} Cov(I_{A_j}, I_{A_{j+1}}) &= E(I_{A_j} \cdot I_{A_{j+1}}) - E(I_{A_j})\cdot E(I_{A_{j+1}})\\ &= p^3 - p^4 \\ &=p^3 (1 - p) \end{align*}

Thus, the variance of $X$ is given as,

\begin{align*} Var(X) &= \sum_{j=2}^{n}Var(I_{A_j}) + 2\sum_{j < k} Cov(I_{A_j},I_{A_k})\\ &=(n-1)p^2(1-p^2)+2(n-1)p^3(1-p) \end{align*}