# Expectation of trials until success

,

## Example 1 - Fair coin

### Problem

What is the average number of tosses we need until reaching a head, given

### Solution

The probability of tossing only once and getting a head

The probability of tossing twice to get a head

The probability of tossing 3 times to get a head

The probability of tossing times to get a head

The expectation of number of tosses until head

\begin{align}
\newcommand{\E}[1]{\text{E}[#1]}
\newcommand{\blueseries}{\color{blue}{\left[ \frac{1}{2} + \frac{1}{2^2} + \frac{1}{2^3} + \dots \right]}}
\E{n} &= \frac{1}{2} + 2\times\frac{1}{4} + 3\times\frac{1}{2^3} + \dots \\
&= \blueseries +
\left[ \frac{1}{2^2} + \frac{1}{2^3} + \frac{1}{2^4} + \dots \right]
\end{align}

Note that the infinite sum of the geometric series

\begin{align}
S &= \sum\limits_{k=0}^{\infty} a r^k = \frac{a}{1 - r} \\
\blueseries &= \frac{1}{2 (1 - \frac{1}{2})} \\
&= 1
\end{align}

The expectation above can be written as the infinite sums of several geometric series

\begin{align}
\newcommand{\bluesum}{\color{silver}{\sum\limits_{k=0}^{\infty} \frac{1}{2} \left( \frac{1}{2} \right) ^2}}
\E{n} &= \bluesum + \frac{1}{2} \bluesum + \frac{1}{4} \bluesum + \dots \\
&= 1 + \frac{1}{2} + \frac{1}{4} + \dots \\
&= 1 + S \\
&= 2
\end{align}