# expectation of number of streaks

#### ogry

##### New Member
Ok so i have this question and i dont even knownwhere to begin.
An unfair coin with the probability of p to get a head is tossed n times. (n>6).
A success is defined as getting ONLY 4 heads in a row.
So that hhhht is a succes for the first 5 tosses
THHHH is a succes for the last five.
And THHHHT is a success for all the rest.
Let Y be the number of successe in n tosses.
Whats the expectation of Y?
I am truely lost.

#### ogry

##### New Member
I would have said what i have done with this so far but to be honest after 3 long hours of trying to figure this out i am no where closer to doing this.
My original line of thought was so somehow define the probability of success as p^4*(1-p)^2 and somehow make it into a binomial distribution but the first and last possibilties cancel that out even though i am not sure it made any since to begin with.
Also tried some brute force to see the expectation for n=6...13 in which y can get a maximum value of 2 but didnt find anything i could generalise from that.

#### BGM

##### TS Contributor
I understand that it is not that straight forward if you have no experience in dealing this before. Maybe I can give you a hints (actually the question is almost over)

Let $$X_i$$ be the indicator of the success, with the 4 consecutive heads on the $$i, i+1, i+2, i+3$$ tosses, $$i = 1, 2, \ldots, n-3$$

Then the total number of successes in $$n$$ tosses will be

$$\sum_{i=1}^{n-3} X_i$$

Let you think about the question first after providing the setup.

#### ogry

##### New Member
I understand that it is not that straight forward if you have no experience in dealing this before. Maybe I can give you a hints (actually the question is almost over)

Let $$X_i$$ be the indicator of the success, with the 4 consecutive heads on the $$i, i+1, i+2, i+3$$ tosses, $$i = 1, 2, \ldots, n-3$$

Then the total number of successes in $$n$$ tosses will be

$$\sum_{i=1}^{n-3} X_i$$

Let you think about the question first after providing the setup.

thank you.
I did actualy think of indicators too.
the thig is. lets say we define it like this
X1 is the even of getting HHHHT on the first 5 tosses with probability of p^4*(1-p)
Xn same thing for the last 5 tosses with the same probability for THHHH
then Xi is the even of THHHHT for all the rest with probability of p^2*(1-p)
then we actualy get that if Xi happens then X1 and Xn are built into that.
then when we sum the Xi's for each THHHHT sequence we get both X1 Xn too.

I should have emphsised HHHHHHHH is not is not 2 succeses. its only if theres four and only four consecutive heads then we get a succes

#### BGM

##### TS Contributor
I am not sure why that bother you, in calculating the expectation. Remember you are calculating the expectation only, not calculating its pmf for the whole distribution, which is much more tedious and this short cut cannot be applied.

Of course those nearby $$X_i$$ are dependent if they involve overlapping tosses. But again that does not matter - you only need the linearity to work. So as you said it is just the sum of all these probabilities.