Problem: What is the expected number of sequences of $3$ heads in $50$ tosses of a coin?
I am a bit confused about this problem in my course. So far we defined expectation value as:
$$E[X]= \sum_{x=0 }^n x \cdot P[X=x] $$
Which tells us the expected value, or mean of a certain experiment. However, now they go and just pick a certain value without explaining how this is done. Normally instead of 3, it would say "$X$". How is this done?
I know that there are $2^{50}$ possible sequences as every entry can be either heads or tails.
This is a straight forward exercise in the use of indicator variables.
Note that a string of the form $HHH$ can start anywhere from the first slot to the $48^{th}$. For $i\in \{1,\cdots, 48\}$ let $X_i$ be the indicator variable for the $i^{th}$ slot. Thus, $X_i=1$ if a good sequence begins on the $i^{th}$ slot and $X_i=0$ otherwise.
By Linearity $$E=E\big [\sum_{i=1}^{48}X_i\big ] =\sum_{i=1}^{48}E[X_i]$$
Now, the $X_i$ don't all have the same expectation, $X_1$ and $X_{48}$ are different than all the others (which all equal each other).
To handle $X_1$ note that the only good sequence that starts in the first slot is $HHHT$. Thus the probability of starting with a good sequence is $\frac 1{16}$, so $E[X_1]=\frac 1{16}$. A similar computation shows that $E[X_{48}]=\frac 1{16}$ as well.
For $1<i<48$ we get a good sequence starting in slot $i$ by $THHHT$, where the first $H$ is in the $i^{th}$ slot. Thus the probability that a good string starts in slot $i$ is $\frac 1{32}$
Combining all this we see that $$\boxed {E=2\times \frac 1{16}+46\times \frac 1{32}=\frac {25}{16}=1.5625}$$