\documentstyle[12pt,twoside,amstex,eepic,psfig]{article}
\input{macros-course-lectures}

\parskip1.5ex
\parindent0pt

\begin{document}

\lecture{notes23}{Notes 23}{May 8, 1997}

Recall that a {\em random variable\/} is a function $R$ from the
sample space of a probability distribution to the reals. \\
\\
In this lecture, we study the important notion of {\em expectation} of
a random variable. \\
Expectation condenses the entire random variable down to a single
number, an ``average''. \\
Obviously, loses lots of information by doing this. 

\section{Definition and Simple Examples}

Fix a probability distribution Pr on sample space S, and let $R$ be a
random variable, $R: S \rightarrow \reals$.

\begin{defin}
The {\bf expected value} or {\bf expectation} or {\bf mean} of random
variable $R$ is
\[
E[R]= \sum_{s \in S} R(s) \cdot \Pr(s)
\]
\end{defin}

This can be stated equivalently (also used often as the definition):

\begin{theorem}
\label{thm2}
$E[R] = \sum_{r \in \reals} r \cdot \Pr(R = r)$
\end{theorem}

\begin{proof}
These are equivalent, because the second is just obtained from the
first by grouping together the points that have the same $R$-value. \\
Formally, 
\begin{eqnarray*}
E[R] &=& \sum_{s \in S} R(s) \cdot \Pr(s) \\
     &=& \sum_{r \in \reals} \sum_{s | R(s) = r} R(s) \cdot \Pr(s) \\
     &=& \sum_{r \in \reals} \sum_{s | R(s) = r} r \cdot \Pr(s) \\
     &=& \sum_{r \in \reals} r \cdot \sum_{s | R(s) = r} \Pr(s) \\
     &=& \sum_{r \in \reals} r \cdot \Pr(R = r) \\    
\end{eqnarray*}
\end{proof}

\begin{example}
Roll 1 six-sided die. \\
Sample space $S$ is the six sides. \\
Random variable $R$ is the number of spots. \\
The mean (calculated by either definition above) is: 
\[
E[R]=\sum_{i=1}^6 i \left(\frac{1}{6}\right) = \frac{1}{6}\frac{6\cdot 7}{2}
= 3.5
\]
\end{example}

Recall than the {\em indicator variable\/} for an event $A$ is the
random variable that's $1$ for elements of $A$, $0$ for elements of
$\bar{A}$.

\begin{example}
If $I$ is the indicator variable for an event $A$, then, calculating
using the second definition:
\begin{eqnarray*}
E[I] &=& 1 \cdot \Pr(I=1)+ 0\cdot\Pr(I=0)\\
&=& 1\cdot\Pr(A)+0\cdot\Pr({\overline{A}})\\
&= & \Pr[A]
\end{eqnarray*}
\end{example}

Very roughly speaking, the expected value is supposed to indicate what
we ``expect'' the value of the random variable to be if we select a
sample point according to the probability distribution. \\
\\
What does this mean? \\
\\
It doesn't really say anything about what will happen on any
particular trial. \\
It does tell us about what should happen when there are a large number
of repeated trials. \\
Next week, we will study a theorem known as the {\em Law of Large
Numbers}, which says that, in a large number of
experiments, the probability is very high that the {\em average}
outcome is close to the expected value. 

\begin{example}
In one die roll, there is no reason to expect an outcome
near $3.5$.  \\
But over many die rolls, the outcomes will almost
certainly average to around 3.5.
\end{example}

Note that the mean doesn't tell much about the distribution. \\
Completely different distributions can have the same mean: \\

\begin{example}
Suppose the die has $3$ sides containing $1$ spot, $3$ sides with $6$
spots. \\
Mean is still $3.5$.
Very different distribution.
\end{example}

The expectation is the weighted average of all possible values of the
random variable. \\
The concept of expectation also arises for continuous random
variables, only there, the sum is replaced by an integral. \\
\\
Expectation is often just called the {\em average}. \\
But be careful -- this is the {\em mean}, not the {\em median}:

\begin{defin}
The {\bf median} of $R$ is the unique value $r \in Range(R)$ such that
$\Pr(R < r) \leq 1/2$ and $\Pr(R > r) < 1/2$. \\
(Sometimes the $\leq$ and $<$ are switched.)
\end{defin}

\begin{example}
Ordinary die. \\
The median is $4$, because the probability that the number of dots is
strictly less than $4$ is exactly $1/2$, while the probability that
the number of dots is strictly greater than $4$ is less than $1/2$. \\
(Sometimes say $3$.)
\end{example}

The median and mean can be very far apart. 

\begin{example}
$2n$-sided die, with $n$ sides having $0$, $n$ having $100$. \\
Mean is $50$. \\
Median is $100$ (or $0$).
\end{example}

\section{Computing the Mean---a Shortcut}

If the range of a random variable is the natural numbers, there is a
different way to express the mean. \\
This can sometimes help in computing it. 

\begin{theorem}
If $R: S \to \naturals$, then 
\[
E[R] =\sum_{i=0}^\infty \Pr(R>i).
\]
\end{theorem}

\begin{proof}
\[
\begin{array}{lllllll}
\sum_{i=0}^\infty \Pr(R>i) & = & \Pr(R>0) + & \Pr(R>1) + & \Pr(R>2) + & \Pr(R>3) + & \Pr(R>4) + \dots  \\
&=&& \Pr(R=1) + & \Pr(R=2) + & \Pr(R=3) + & \Pr(R=4) + \dots \\
&&&&             \Pr(R=2) + & \Pr(R=3) + & \Pr(R=4) + \dots \\
&&&&&                       \Pr(R=3) + & \Pr(R=4) + \dots \\
&&&&&&                                  \Pr(R=4) + \dots \\
&=& \sum_{i=1}^\infty i \Pr(R=i) \\
&=&E[R]
\end{array}
\]

\end{proof}

We give an example to show the use of this shortcut. \\
\\
Suppose we are given a system that might fail at any of the discrete
times $1, 2, \ldots$. \\
Failure at each time step is independent, probability $p$. \\
Let $R$ be the number of non-failing times that pass prior to the
first failing time. \\
Then $R$ is distributed according to the {\em geometric
distribution}:
\[
\Pr(R=k) = p(1-p)^k,
\]
since this is the probability that the first $k$ steps are non-failing
(``successful'') and the $(k+1)^{st}$ is a failure. \\
\\
What is our sample space? \\
Finite sequences of successes followed by one failure, \\
together with one infinite sequence, of all successes. \\
So it's countable. \\
\\
The probability of a sequence of $k$ successes followed by $1$ failure
is as given above. \\
The probability of the sequence of all successes is $0$. \\
(Possible event, but probability is $0$ -- that actually makes sense.) \\
\\
The sum of all these probabilities is:
\[
p + p(1-p) + p(1-p)^2 + \ldots = {p \over 1 - (1-p)} = 1
\]
as needed. \\
\\
The random variable $R$ associates $k$ with the sequence of $k$
successes and $1$ failure. \\
(Associate some arbitrary default with the infinite sequence -- it
won't matter, for our purposes, because that has probability $0$
anyway). \\
\\
What is the expected value of $R$? \\
(This is usually called the {\em mean time to failure\/} (MTF). \\
\\
Use the shortcut to calculate. \\
\\
The event $R > i$ occurs when the first $i+1$ trials are all
successes. \\
Thus, 
\[
\Pr(R>i)= (1-p)^{i+1}
\]
Therefore, using the shortcut sum,
\[
E[R]=(1-p)+(1-p)^2 +(1-p)^3 + \dots = \frac{1-p}{1-(1-p)} =
\frac{1-p}{p}
\]

It follows that the expected number of successes before the first
failure is $\frac{1-p}{p}$. \\
This means that the failure occurs at step $1+\frac{1-p}{p} = \frac{1}{p}$.

Note: probability (no failures in $k$ MTFs) is $(1-p)^{k/p}<e^{-k}$,
ie exponential dropoff.

\begin{example}
Consider a couple that wants to have a girl. \\
Assume girls and boys are equally likely.  \\
What is the expected number of boys before the first girl? \\
\\
Here, $p=1/2$.  \\
The girl is analogous to a system failure (not to be taken literally).
\\
From the above analysis, the expected birth-number of the girl is:
\[
E[R] = \frac{1}{p} = \frac{1}{1/2} = 2
\]
Thus, you expect only one boy before the first girl. \\
So the average family size is $2$!  \\
This might seem counterintuitive, since you would expect the attempts
to have a girl to lead to long sequences of boys; \\
however, these sequences are counterbalanced by the chance of having a
girl on the first try.
\end{example}

\section{Linearity of Expectation}

\subsection{The Results}

It turns out that expectation is a ``linear function'':

\begin{theorem}
\label{thm1}
For any random variables $R$, $R_1$, $R_2$ and any real constant $a$,
the following hold:
\begin{enumerate}
\item
$E[aR] = a E[R]$
\item
$E[R_1 + R_2] = E[R_1] + E[R_2]$
\item
$E[R + a] = E[R] + a$
\end{enumerate}
\end{theorem}

Note that we do not need to assume independence of the random
variables.

\begin{example}
Roll two $6$-sided dice. \\
Let $R_1$ and $R_2$ be the outcome of the 1st and 2nd die,
respectively. \\
Also, let $R = R_1 + R_2$ be the sum. \\
Then
\[
E[R] = E[R_1]+E[R_2] = 3.5 + 3.5 =7
\]
\end{example}

\begin{proof}
We first show $E[aR] = a E[R]$. \\
Can be done using either definition of expectation. \\
I'll use the first definition, since it's easier. \\
\begin{eqnarray*}
E[aR] &=& \sum_{s \in S} a R(s) \Pr(s) \\
      &=& a \sum_{s \in S} R(s) \Pr(s) \\
      &=& a E[R]
\end{eqnarray*}

Using the second definition, it's a little harder:
\begin{eqnarray*}
E[aR] &=& \sum_r r \Pr(aR=r) \\
      &=& \sum_r r \Pr(R=r/a) \\
      &=& \sum_{r'} ar' \Pr(R=r')\quad  \mbox{ (substitute $r'=r/a$)}\\
      &=& a \sum_{r'} r' \Pr(R=r') \\
      &=& aE[R]
\end{eqnarray*}

We next show $E[R_1 + R_2] = E[R_1] + E[R_2]$:
\begin{eqnarray*}
E[R_1 + R_2] &=& \sum_{s \in S} (R_1(s) + R_2(s)) \Pr(s) \\
      &=& \sum_{s \in S} R_1(s) \Pr(s) + \sum_{s \in S} R_2(s) \Pr(s) \\
      &=& E[R_1] + E[R_2] 
\end{eqnarray*}

Finally, we show $E[R + a] = E[R] + a$.
\begin{eqnarray*}
E[R + a] &=& \sum_{s \in S} (R(s) + a) \Pr(s) \\
      &=& \sum_{s \in S} R(s) \Pr(s) + \sum_{s \in S} a \Pr(s) \\
      &=& E[R] + \sum_{s \in S} a \Pr(s) \\
      &=& E[R] + a \sum_{s \in S} \Pr(s) \\
      &=& E[R] + a 
\end{eqnarray*}
\end{proof}

LTTR to show the last two parts using the second definition.

\begin{corollary}
$E[a_1 R_1 + a_2 R_2] = a_1 E[R_1] + a_2 E[R_2]$.
\end{corollary}

\begin{proof}
\begin{eqnarray*}
E[a_1 R_1 + a_2 R_2] &=& E[a_1 R_1] + E[a_2 R_2] \\
                     &=& a_1 E[R_1] + a_2 E[R_2]
\end{eqnarray*}
\end{proof}

\begin{corollary}
$E[R_1+R_2+R_3+\dots + R_N] = E[R_1] + E[R_2] + E[R_3]+ \dots E[R_N]$
\end{corollary}

\begin{proof}
By induction, based on Theorem \ref{thm1}, part 2.
\end{proof}

\subsection{Simple Examples}

\begin{example}
(Hat Check Problem)

$n$ men check their hats at a restaurant. \\
The perverse hat check person scrambles the hats randomly (random
permutation). \\
What is the expected number of men to get their own hat? \\
\\
Let the random variable $R$ denote the number of men to get their own
hat back. \\
$\Pr(R=k)$ is difficult to calculate directly. \\
\\
However, we can get some help by expressing $R$ in the form of a sum
of auxiliary random variables. \\
Namely, define $R_i$ as
\[
R_i = \left\{ \begin{array}{ll}
                1 & \mbox{if the ith man gets his hat} \\
                0 & \mbox{otherwise}
              \end{array}
        \right.,
\]
That is, the indicator variable for the event that man $i$ gets his
hat back. \\
\\
Then clearly $R = R_1 + R_2 + R_3 + \dots + R_n$.
Obviously, the $R_i$ are not independent. \\
For example, if $R_1=R_2=\ldots R_{n-1} =1$, then $R_n=1$. \\
Nevertheless, we can apply linearity of expectation. \\
\\
Note, $E[R_i] = 1 \cdot \Pr(R_i=1) +0 \cdot \Pr(R_i=0) = 1/n$. \\
This is because there is a $1$ in $n$ chance that man $i$ gets his own
hat. 
\[
E[R] = E[R_1] + E[R_2] + \dots + E[R_n] = n(1/n) =1
\]

So, you expect one man to get his hat back.
\end{example}

\begin{example}
(Chinese appetizer problem)

$n$ people at a circular table.  \\
$n$ different appetizers on a Lazy Susan. \\
The Lazy Susan is randomly rotated. \\
What is the expected number of people who get the same appetizer? \\
\\
Answer: 1.  \\
Same reasoning as above.  \\
The expectation for each individual person is 1/n. \\
Therefore, the expectation for $n$ people is 1. \\
\\
Note that the probability space is very different from the hat check
problem.  \\
There are only $n$ distinct outcomes, instead of the $n!$ in the hat
check problem. \\
Either everyone gets the same appetizer back (probability $1/n$) or no
one does. \\
Nevertheless, we can solve both problems easily by using
linearity of expectation. \\
We didn't need to know much about the actual distribution. \\
Also, we don't need independence.
\end{example}

\begin{example}
(Negative Binomial Distribution/Pascal Distribution as taught by Al
Drake in 6.041)

Carry out as many Bernoulli trials as necessary, until $k$ failures
(prob. $p$) occur.  How long till the $k^{th}$ failure?

Probability $k^{th}$ failure at time $n$ or in $n$ trials is prob.
$k-1$ failures before $n$ and a failure at time $n$:
\[
{n-1 \choose k-1}p^{k-1}(1-p)^{n-k}\cdot p = {n-1 \choose k-1}p^{k}(1-p)^{n-k}
\]

Infinite discrete probability space.


What is the expected number of trials up to and including the $k$
failure?  Let $T_j$ be time(the number of trials) after failure number
$j-1$ up to failure $j$.  Then value we want is $\sum_{j=1}^k T_j$.
Therefore, the random variable that describes the number of trials up to and
including the $k^{th}$ filure is a sum of $k$ geometric random
variables. Thus, the expectation is $k\cdot E[T_j]=k/p$.

\end{example}

\subsection{Combinations of Events}

Can use linearity to calculate how many of an arbitrary set of events
are likely to occur. \\
The events needn't be independent. 

\begin{theorem}
Given any collection of $n$ events, $A_1, A_2, A_3, \ldots A_n$.
Then the expected number of these events that occur is 
\[
\sum_i Pr (A_i).
\]
\end{theorem}

Just add up the probabilities!

\begin{proof}
Let $R_i$ be the indicator variable for $A_i$.  \\
That is,
\[
R_i = \left\{ \begin{array}{ll}
                1 & \mbox{if event $A_i$ occurs} \\
                0 & \mbox{otherwise}
              \end{array}
        \right.
\]

Then the total number of the events that occur is:
\[ 
R= R_1 + R_2 +\dots + R_n
\]
We want the expected value of $R$.
\begin{eqnarray*}
E[R] & = & \sum_i E[R_i] \\
     &=& \sum_i \Pr(A_i) 
\end{eqnarray*}
\end{proof}

\begin{example}
Suppose I flip $n$ coins, independently. \\
Let $R$ = total number of heads. \\
What is the expected number of heads, $E[R]$? \\
\\
Can calculate directly: 
\[
E[R] = \sum_{i=0}^n i \Pr(R=i) = \sum_{i=0}^n i {n \choose i} 2^{-n}
\]
Using the fact (LTTR) that
\[ 
\sum_{i=0}^n i {n \choose i} = n 2^{n-1}
\]
we see that this is $n/2$. \\
\\
\\
Let's get a simpler proof using combinations of events. \\
\\
Define $A_i$ to be the event that the $i$th flip yields heads. \\
$R(s)$ is just the total number of events $A_i$ containing the sample
point $s$. \\
\\
By the theorem above, $E[R] = \sum_i \Pr(A_i)$. \\
Since each $\Pr(A_i) = 1/2$, this yields $n/2$. \\
\\
Can see this as a probabilistic proof of the combinatorial identity:
\[
\sum_{i=0}^n i {n \choose i} 2^{-n} = n/2
\]
The two sides compute the same expectation, so they must be equal.
\end{example}

Besides being easier, the expectation argument is also more powerful.
\\
It doesn't assume independent distributions on the coins.  \\
\\
We can extend the preceding to show that if we conduct $n$ independent
trials, each succeeding with probability $p$, then the expected number of
successes is $np$. \\
That is, the mean of the binomial distribution is $np$.  \\
(Because the probability of $k$ successes is given by the binomial
term ${n \choose k} p^k (1-p)^{n-k}$.)

\begin{example}
Suppose I make one random choice, to either use an all heads coin or
an all tails coin in my $n$ coin flips. \\
Now there are only two sample points, one with all heads in the
sequence and one with all tails. \\
\\
But for each event $A_i$, the probability is still $1/2$. \\
So the theorem still applies, yielding $n/2$ as the expected number of
heads.
\end{example}

\begin{example}
Consider a 6-sided die. \\
$A_1$ is the event that the value is odd. \\
$A_2$ is the event that the value is 1, 2 or 3 \\
$A_3$ is the event that the value is 4, 5, or 6 \\
\\
Not independent. \\
In fact, the last two exclude each other. \\
\\
But we can still calculate the expected number of these events that
hold as $\Pr(A_1) + \Pr(A_2) + \Pr(A_3) = 1/2 + 1/2 + 1/2 = 3/2$.
\end{example}

\section{Extra Problems}

\subsection{Coupon Collecting}

Suppose there are $n$ different baseball cards.  I buy them one at a
time and stop when I get one of each.  How long do I expect to
continue?

Let $W_k$ be the time I wait until I get the $k^{th}$ card, and let
$X_k = W_{k+1}-W_k$.  Then clearly, 
\[
W_n = \sum X_k
\]
and therefore the waiting time is
\[
\sum E[X_k].
\]
To determine $E[X_k]$, consider the ``experiment'' being performed
during this $k^{th}$ time interval.  I have $k$ cards, and I want to
find the $(k+1)^{st}$.  Each time I buy a card, my probability of
getting a new card is $p=(n-k)/n$.  Each attempt is independent, so I
have a sequence of Bernoulli Trials.  By the previous example on
negative binomial distributions (``mean time to failure,'' only now
it is success) my expected waiting time is
\begin{align*}
\frac{1}{1-p} &= \frac{1}{1-k/n}\\
&= \frac{n}{n-k}
\end{align*}
Like in the negative binomial distribution example this is also a sum
of $n$ geometric random variables but unlike the neg. binomial example
each geometric random variable has a different distribution.  It
follows that the expected waiting time to get all the cards is
\begin{align*}
\sum_{k=1}^{n-1} \frac{n}{n-k} &= n \sum_{k=1}^{n-1} \frac{1}{k}\\
&\approx n \ln n
\end{align*}
where the last approximation comes from our recognition of the {\em
  Harmonic series}.

(So to get all $1000$ distinct baseball cards, we expect to buy about
$7000$).

We were actually a bit sloppy in our analysis of the coupon collecting
problem.  When we talked about the experiment in the $k^{th}$ time
interval, we referred to the trials being done in this interval.  But
which trials in our sequence of purchases make up the $k^{th}$
experiment?  The ones after we got $k$ cards.  It follows that we are
actually conditioning on a particular value of $W_k$.  In other words,
we are computing $E[X_k]$ using conditional expectations!  What saves
us is that $E[X_k]$ turns out to be independent of $W_k$:
\begin{align*}
E[X_k] &= \sum_z E[X_k \mid W_k = z] \cdot \Pr[W_k=z]\\
&= \sum_z \frac{n}{n-k} \Pr[W_k=z]\\
&= \frac{n}{n-k}  \sum_z \Pr[W_k=z]\\
&= \frac{n}{n-k} 
\end{align*}

\subsection{Carnival Game}

Let's consider the following carnival game.
\begin{itemize}
\item Player picks $A\in [1,6]$.  

\item Roll 3 six-sided dice.  (Assume fair and mutually independent).

\item If the player matches any of the dice, he wins \$1.  Otherwise, he loses
\$1.
\end{itemize}

Let $R$ denote the player's winning.
Then, $E[R] = 1\cdot \Pr(win) - 1\cdot \Pr(lose)$.

One initial approach may be as follows.  The probability of die 1 matching
is 1/6.  Similary, the probability of die 2 and die 3 matching is 1/6.
Therefore, the probability of getting one match is 3/6.  Thus, the game
is fair, and $E[R] = 0$.

This analysis is wrong.  $Pr(win)\neq 1/2$.  What was the problem?
Well, we imagined an indicator variable for each die: $I_k$ says die
$k$ is a winner.  But then we claimed that $I=I_1+I_2+I_3$ is an
indicator variable for whether the player wins.  This is wrong, since
$I$ isn't an indicator for anything: its value may be $2$ or $3$.
$\sum I_k$ actually measures the {\em expected number of matching
  dice}, a different quantity.  Indicator variables need to be $0,1$.

The correct method is to apply inclusion/exclusion.
\begin{eqnarray*}
Pr(R=1) & = & \Pr(D_1= A \vee D_2 =A \vee D_3=A) \\
&=& Pr (D_1=A) + \Pr(D_2=A) + \Pr(D_3=A) - \Pr(D_1=A \wedge D_2=A) \\
&&-
Pr(D_1=A \wedge D_3=A) - \Pr(D_2=A \wedge D_3=A) + \Pr(D_1=A \wedge D_2=A \wedge D_3=A)\\
&=& 1/6 + 1/6 + 1/6 - 1/36 - 1/36 - 1/36 + 1/216\\
&=& .421
\end{eqnarray*}

Another way to calculate this probability is to find the probability
of a loss.  $Pr(lose) = (5/6)^3 = .579 \implies \Pr(win)=1-.579=.421$.

Thus, the game is an expected loss.
Another variant of the game is to pay \$2 if two dice match.
Again, this is a losing game.

\subsection{A two-player game}

Here's a game you don't want to play unless you know what you're doing.
Two players, $A$ and $B$, agree on a probability distribution $f(x)$
for a random variable $X$ over $\naturals$.  That is, $f(x) = Pr(X = x)$.

Now player $A$ picks a number $a$ at random according to $f$.
Then player $B$ independently picks a number $b$ according to $f$;
if $b \leq a$, then $B$ repeats this until she gets a number 
$b > a$.  Each time through the loop, $B$ pays $A$ \$1.

What is $B$'s expected loss?  The answer is $\infty$.  

To get some intuition for this, consider first the finite case: 
$f(x)$ is non-zero only for a finite set of numbers.  Let $t$ be
the largest such number.  Then with positive probability, $A$
will pick $t$, in which case $B$ can never pick a bigger number
and so her loss will be infinite.  

More precisely, if $R$ is a random variable denoting the number
of times $B$ pays \$1, then we have
$$E[R] = \sum_{x \in \naturals} Pr(R > x).$$
But $Pr(R > x) \geq f(t)$ for all $x \geq t$, so this sum is infinite.

Now let's consider the case of an arbitrary distribution function $f$.
Here, there may be no ``biggest number'' $t$, so we have to use a
different argument.  

Consider the game as follows: $A$ draws the first number, and then
$B$ draws infinitely many more numbers, paying \$1 until a number
comes up that's bigger than the first number.  So $B$ will pay at least \$m
if among the first $m$ numbers, the first is biggest.

For a fixed $m$, let $A$ denote this event: that the first of $m$ numbers
drawn according to $f$ is the biggest.  We claim that $Pr(A) = \frac{1}{m}$,
regardless of $f$.  Intuitively, this is because only the order in
which the numbers arrive matters.  We can prove this as follows:

The sample space is the set $S$ of all $m$-vectors of numbers.  Let's
say that two such vectors are equivalent if one is a permutation of
the other.  This gives a partition of $S$ into equivalence classes:
$S = \cup_i M_i$ and $\sum_i Pr(M_i) = 1$.

Now for each $i$, we have $Pr(A \mid M_i) \geq \frac{1}{m}$, since
one we've fixed the $m$ numbers, all orders are equally likely.
(We don't necessarily have equality since numbers can be repeated.)
Now we have
\begin{eqnarray*}
Pr(A) & = & \sum_i Pr(M_i) \cdot Pr(A \mid M_i) \\
& \geq & \frac{1}{m} \sum_i Pr(M_i) \\
& = & \frac{1}{m}.
\end{eqnarray*}
Finally, we can compute the expected loss:
$$ER = \sum_{m \in \naturals} Pr(R > m) \geq \sum_{m \in \naturals} \frac{1}{m} = \infty.$$

\subsection{Another two-player game}

You remember Monty Hall?  Well, not satisfied with the money 
{\em Let's Make a Deal} is making in syndication, he's turned to 
other sorts of games.  Here's one: 

There are two envelopes, one containing twice as much money as the
other.  He gives you one, but he does not allow you to open it. He
then asks whether you want to keep the envelope, or switch.
Should you?

Here's some incorrect reasoning: lets say you have $\$x$ in your
current envelope; so with probability $\frac12$ the other envelope has
$\$(2x)$, and with probability $\frac12$ the other envelope has
$\$x/2$.  So your expected gain on swapping is $x/2 - x/4 = x/4$ ---
that is, you should always swap!

But this argument is incorrect, and the reason is that the probability
is not 50-50 that the other envelope has either twice or half as much.
For example, suppose I randomly put \$1 and \$2 in two envelopes.  
You open one and it contains \$2.  What is the probability that
the other envelope contains \$4?  It's zero.

A correct argument, which gives the intuitively reasonable answer
that it makes no difference whether you switch, is the following.
One envelope has $\$y$ and the other has $\$2y$.  So if you open
an envelope and see $\$x$, then either $x = y$ with probability $\frac12$,
or $x = 2y$ with probability $\frac12$.  So in the first case
your gain on switching is $x$, and in the second your gain is $-x$.
Thus your expected gain is zero.

Now Monty allows you to open the envelope in hand, revealing $\$x.$
Again he asks whether you want to keep the money, or switch. Given
this extra information - the actual number $x$ - should you switch or
not. Intuitively, it would seem that knowing the number $x$ does not
give you any edge and so it shouldn't matter whether you switch or
not. But, in actuality there is a strategy which allows you to pick
the larger of the two sums with probability better than $\frac12$. The
strategy is as follows - choose any distribution which has continuous
support over the reals, like the normal distribution, and pick a
number $r$ from it, if $r > x$ then switch, otherwise stay. Note that
whenever $r$ is smaller than the lesser of the two sums or bigger than
the greater of the two then we end up with the larger sum with
probability $\frac12$, but whenever $r$ lies in between the two sums
then we always end up with the larger sum. Thus we do better than
$\frac12$, since there is a non-zero probability of $r$ landing
exactly between the two sums. Note, however, that if we use the normal
distribution to pick $r$ then if the sums in question grow very large
our probability of winning the larger amount goes to $\frac12$. In
fact it can be shown that there is no distribution that can guarantee
us a winning probability greater than $\frac12$ by any fixed constant.



Of course, all this assumes that Monty offers the switch regardless of
how much money he sees you holding.  Where do we use this fact?

\end{document}

Problems:

1. (Negative binomial distribution)

Consider a system consisting of $2$ components, each of which can
fail at each step, with probability $p$.
Their failures are independent of each others.

(a) What is the expected number of time steps at which neither of them
has failed?

(b) What is the expected number of time steps at which at least one of
them has not failed?

2. (Linearity of expectations)

The same $n$ college students apply to two graduate schools, $A$ and
$B$.  
In order to same money and time, each grad school ranks the students
randomly, with all permutations chosen with equal likelihood.

(a) What is the expected number of students that have a higher rank on
the list for grad school B than they do for grad school A?

(b) What is the expected number of students that have a rank on the
list for grad school B that is at least $k$ higher than their rank on the
list for grad school A?

3. (Conditional expectation)

A medical insurance company insures subscribers from three separate
pools, A, B and C, all containing the same number $n$ of subscribers.
Individuals in pool A have a 1% chance of developing a major illness in a
given year, those in pool B a 5% chance and those in pool C a 25% chance.
Each major illness costs the insurance company $10,000.
The law requires that the company charge everyone equal rates for
insurance. 

If a subscriber is chosen at random from the union of all three
pools, what is the expected amount of payout from the insurance
company to that subscriber in a given year?

(You may assume that no one develops more than one major illness.)


4. (Wald's theorem)

Consider the following $3$-stage experiment:

In the first stage, I throw a 6-sided die.  The number of spots that I
determines how many instances of the second stage to perform.

In the second stage, I throw a 6-sided die.  The number of spots that I
determines how many instances of the third stage to perform.

In the third stage, I throw a 6-sided die.  

My score is the total number of spots on all the instances of the
third stage.

What is my expected score?

(Analyze this as carefully as you can, using Wald's theorem.  Try to
be careful about uses of independence.)

[[[Mojdeh:  Please work these out carefully -- see that they are
reasonable.  ]]]
