\problemdata      
        {?} % latex-friendly label for the prob.
        {Probability-Expectation} % The topic(s) of the problem content.
        {?} % Source (if known)
        {F01, TU11-5} % Usage (list ones you are aware of).
        {Christos Kapoutsis, S02} % Last revision info (author, date).

\begin{problem}
What are each of the following quantities when $n$
independent Bernoulli trials are carried out with probability of
success $p_s$?

\problempart The probability of no failures
\problempart The probability of at least one failure
\problempart The probability of at most one failure
\problempart The expected number of failures in $n$ trials
\problempart The expected number of trials before the first failure

\solution{

Let $F$ be a random variable equal to the number of failures in $n$
trials.

\begin{eqnarray*}
\prob{F=0}  &=& {p_s}^n \\
\prob{F>0}  &=& 1-\prob{\text{No failure}} = 1-{p_s}^n\\
\prob{F\leq 1} &=& \prob{F=0}+\prob{F=1}\\
            &=& {p_s}^n + n(1-{p_s}){p_s}^{n-1}\\
\end{eqnarray*}

\begin{eqnarray*}
\expect{F} &=& \sum_{i=0}^{n} i\prob{F=i} \\
           &=& \sum_{i=0}^{n} i \binom{n}{i}(1-{p_s})^i {p_s}^{n-i}\\
           &=& n(1-{p_s})\\
\end{eqnarray*}

It is worthwhile to remember the expectation of a binomial
distribution. But you can always derive it easily by using the
linearity of expectations, i.e. by assigning a random variable $R_j$
to each trial $j$ that has the value 1 if the trial is a success and 0
if not, and then summing those expectations. You can verify that you
get the same answer. This is also explained in detail in
\href{http://theory.lcs.mit.edu/classes/6.042/fall01/lectures/l12.pdf}
{Lecture Notes 12} Section 7.5.

(e) Let $T$ be a random variable representing the number of trials before
the first failure. The best way to solve this sort of problem is to
calculate the probability that it takes more than $k$ trials before a
failure occurs and use the corresponding expectation formula. This is
similar to the Mean Time to Failure problem.

\begin{eqnarray*}
\expect{T} &=& \sum_{i=0}^{n} \prob{T>i} \\
           &=& \sum_{i=0}^{n} {p_s}^i\\
           &=& \frac{1-{p_s}^{n+1}}{1-{p_s}}\\
\end{eqnarray*}

The last line is assuming that this is a geometric series. Note that
unlike the Mean Time to Failure example, the series is not from 0 to
infinity.
}

\end{problem}