Question: I want to solve following question on probability distribution:

> 
> A coin is tossed repeatedly and probability that a head appears at any toss is $p$ where $0<p<1$. What is the expected length of initial run ?
> 
> 
> 

---

A run of length $r$ is $r$ consecutive toss that are all the same. (e.g. $HTTHH$ has a run of length $1$ and two runs of length $2$).

Let us assume, we need $r$ tosses until first head appears, then the probability distribution function $$m(r)=(1-p)^{r-1}p.$$
If $t$ be the time of first head, then expectation of head $H$ is $$E(t)=1 \cdot p+(1-p)p+\cdots.$$
If $r=1$, then always the length of run is $1$.

If $r=2$, then we have $HH,TT,TH,HT$, so there are two runs ($HH, TT$) of length $2$ half of the time and two runs $(HT,TH$) of length $1$ half of the time.

But I am confused with the term "initial run" in my question. What does mean it ?

Answer: 
"But I am confused with the term "initial run" in my question. What does mean it ?"

In e.g. $HHTHTT$ the initial run is $HH$, in e.g. $TTTHHT$ the initial run is $TTT$.

I hope that these examples are enough to make clear what is meant by "initial run".

---

Problems of this sort can often be solved without looking too much at distributions.

Let $\mu$ denote the expectation of the length of the first run.

Let $\mu\_H$ denote the expectation of the length of the first run under condition that the first toss results in heads.

Let $\mu\_T$ denote the expectation of the length of the first run under condition that the first toss results in tails.

Defining $q:=1-p$ we find:$$\mu\_H=p(1+\mu\_H)+q1=1+p\mu\_H\text{ and }\mu\_T=q(1+\mu\_T)+p1=1+q\mu\_T$$leading to:$$\mu\_H=q^{-1}\text{ and }\mu\_T=p^{-1}$$
Then finally we find:$$\mu=p\mu\_H+q\mu\_T=pq^{-1}+qp^{-1}$$Of course you can make it an expression in $p$ only by substituting $q=1-p$.
$E$(length of run)$ = (1 + $E(length until we see tails given first is head)$)\*p+ (1 + $E(length until we see heads given first is tails) $)\*(1-p)$

$E = p\*(1 + 1/(1-p)) + (1-p)\*(1 + 1/p) $ [1/p => expected number of tosses until we see a head and likewise for tails also]

$= p(2-p)/(1-p) + (1-p)(p+1)/p = (2p^2 - p^3 + 1 - p^2 - p + p^3)/(p(1-p))$

Hence, $E = (p^2 - p + 1)/(p\*(1-p))$ tosses