# Expected number of sequences

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.

• Some clarification might be needed. Suppose your string was $HHHH$. Is that two sequences of three heads? – lulu Dec 11 '18 at 15:54
• I think they count that as 1. So far we have only been counting $3$ and then we stop. – Wesley Strik Dec 11 '18 at 15:56
• Well, you need to clarify that point. Either way, though, you can do it with indicator variables. For $i\in \{1,\cdots, 48\}$ let $X_i$ be the indicator variable which is $1$ if a "good" block (however defined) starts at the $i^{th}$ slot. Easy to compute the expected value of $X_i$ and then use Linearity. – lulu Dec 11 '18 at 15:57
• This sounds way too advanced for a first lecture into introductory probability theory. We only know linearity and coin tosses. – Wesley Strik Dec 11 '18 at 16:00
• I don't see an easier way of doing the problem. And indicator variables are pretty easy to use. I suggest looking that up. – lulu Dec 11 '18 at 16:05

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 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}$$

• Why is $TTT$ a good string? As I read the problem we need $THHHT$ if we are in the middle. We can delete one $T$ at the ends. – Ross Millikan Dec 11 '18 at 16:23
• @RossMillikan My computation takes all that into account, or at least it intends to. My point was that a $3-$ sequence, either $HHH$ or $TTT$ can start anywhere from slot $1$ to slot $48$. – lulu Dec 11 '18 at 17:30
• @RossMillikan Oh, sorry. for some reason I read the problem as looking for three of a kind in a row. Now I see that only Heads is accepted. I'll edit accordingly. – lulu Dec 11 '18 at 17:32
• @RossMillikan reviewing the edit history, the problem originally did accept $HHH$ or $TTT$, the OP changed it at some point after I had posted my solution. Anyway, I have edited my solution to correspond to the question in its present form. – lulu Dec 11 '18 at 17:35