Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Now that we have a few ways to think about expectation, let’s see why it has such fundamental importance. We will start by directly applying the definition to calculate some expectations. In subsequent sections we will develop more powerful methods to calculate and use expectation.

8.2.1Constant

This little example is worth writing out because it gets used all the time. Suppose a random variable XX is actually a constant cc, that is, suppose P(X=c)=1P(X = c) = 1. Then the distribution of XX puts all its mass on the single value cc, and E(X)=c1=cE(X) = c\cdot 1 = c. We just write E(c)=cE(c) = c.

8.2.2Bernoulli and Indicators

If XX has the Bernoulli (p)(p) distribution, then P(X=1)=pP(X = 1) = p and P(X=0)=1pP(X = 0) = 1-p. So

E(X)=0(1p) + 1p = pE(X) = 0 \cdot (1-p) ~ + ~ 1 \cdot p ~ = ~ p

As you saw earlier, zero/one valued random variables are building blocks for other variables and are called indicators.

Let AA be any event. Then the indicator of AA is the random variable IAI_A that is 1 if AA occurs and 0 if AA doesn’t occur. Thus IAI_A is has the Bernoulli (P(A))(P(A)) distribution and

E(IA)=P(A)E(I_A) = P(A)

by our calculation above. Thus every probability is an expectation. We will use this heavily in later sections.

x = [0, 1]
qp = [0.75, 0.25]
bern_1_3 = Table().values(x).probabilities(qp)
Plot(bern_1_3, show_ev=True)
plt.title('Bernoulli (0.25)');
<Figure size 432x288 with 1 Axes>

8.2.3Uniform on an Interval of Integers

Let aa and bb be two integers such that a<ba < b. If XX has the uniform distribution on the integers a,a+1,a+2,,ba, a+1, a+2, \ldots, b, then by symmetry, E(X)E(X) is half-way between aa and bb. That’s where the probability histogram will balance. So

E(X)=a+b2E(X) = \frac{a+b}{2}

For example, if XX has the uniform distribution on 1,2,,n1, 2, \ldots , n, then

E(X)=n+12E(X) = \frac{n+1}{2}

An instance of this is if XX is the number of spots on one roll of a die. Then E(X)=3.5E(X) = 3.5.

If instead XX is uniform on 0,1,2,,n0, 1, 2, \ldots , n, then

E(X)=n2E(X) = \frac{n}{2}
x = np.arange(10)
probs = 0.1*np.ones(10)
unif_10 = Table().values(x).probabilities(probs)
Plot(unif_10, show_ev=True)
plt.title('Uniform on Integers 0, 1, 2, ..., 9');
<Figure size 432x288 with 1 Axes>
🎥 See More
Loading...

8.2.4Poisson

Let XX have the Poisson (μ)(\mu) distribution. Then

E(X)=k=0keμμkk!=eμμk=1μk1(k1)!=eμμj=0μjj!=eμμeμ=μ\begin{align*} E(X) &= \sum_{k=0}^\infty k e^{-\mu} \frac{\mu^k}{k!} \\ \\ &= e^{-\mu} \mu \sum_{k=1}^\infty \frac{\mu^{k-1}}{(k-1)!} \\ \\ &= e^{-\mu} \mu \sum_{j=0}^\infty \frac{\mu^j}{j!} \\ \\ &= e^{-\mu} \mu e^{\mu} \\ \\ &= \mu \end{align*}

We now have an important new interpretation of the parameter of the Poisson distribution. We saw earlier it was close to the mode; now we know that it is also the balance point or expectation of the distribution. The notation μ\mu was chosen to stand for “mean”.

k = np.arange(15)
poi_2_probs = stats.poisson.pmf(k, 2)
dist_poi_2 = Table().values(k).probabilities(poi_2_probs)
Plot(dist_poi_2, show_ev=True)
plt.title('Poisson (2)');
<Figure size 432x288 with 1 Axes>
🎥 See More
Loading...

8.2.5Tail Sum Formula

To find the expectation of a non-negative integer valued random variable it is sometimes quicker to use a formula that uses only the right hand tail probabilities P(X>k)=1F(k)P(X > k) = 1 - F(k) where FF is the cdf of XX and k0k \ge 0.

For non-negative integer valued XX,

E(X)=P(X=1)+2P(X=2)+3P(X=3)+E(X) = P(X=1) + 2P(X=2) + 3P(X=3) + \cdots

Rewrite this as

E(X) = P(X=1)+ P(X=2)+P(X=2)+ P(X=3)+P(X=3)+P(X=3)+ P(X=4)+P(X=4)+P(X=4)+P(X=4)+              +             +             +              \begin{align*} E(X) ~ = ~ &P(X=1)\\ + ~ &P(X=2) + P(X=2)\\ + ~ &P(X=3) + P(X=3) + P(X=3)\\ + ~ &P(X=4) + P(X=4) + P(X=4) + P(X=4)\\ + ~ & ~~~~~~~~ \vdots ~~~~~ + ~~~~~~~~ \vdots ~~~~~ + ~~~~~~~~ \vdots ~~~~~ + ~~~~~~~~ \vdots ~~~~~~ \end{align*}

Add the terms along each column on the right hand side to get the tail sum formula for the expectation of a non-negative integer valued random variable.

E(X)=P(X>0)+P(X>1)+P(X>2)+ = k=0P(X>k)E(X) = P(X > 0) + P(X > 1) + P(X > 2) + \cdots ~ = ~ \sum_{k=0}^\infty P(X > k)

This formula comes in handy if a random variable has tail probabilities that are easy to find and also easy to sum.

8.2.6Geometric

In a sequence of i.i.d. Bernoulli (p)(p) trials, let XX be the number of trials till the first success. We will use the word “till” to mean “up to and including”.

Let q=1pq = 1-p. The distribution of XX is given by

P(X=k) = P(k1 failures followed by a success) = qk1p,  k=1,2,3,P(X = k) ~ = ~ P(k-1 \text{ failures followed by a success}) ~ = ~ q^{k-1}p, ~~ k = 1, 2, 3, \ldots

This is called the geometric (p)(p) distribution on {1,2,3,}\{1, 2, 3, \ldots \} because the probabilities are terms in a geometric series.

The right tails of XX are simple because for each k1k \ge 1,

P(X>k) = P(first k trials are failures) = qkP(X > k) ~ = ~ P(\text{first } k \text{ trials are failures}) ~ = ~ q^k

The formula is also true for k=0k = 0 because P(X>0)=1=q0P(X > 0) = 1 = q^0.

By the tail sum formula,

E(X) = k=0qk = 11q = 1pE(X) ~ = ~ \sum_{k=0}^\infty q^k ~ = ~ \frac{1}{1-q} ~ = ~ \frac{1}{p}
🎥 See More
Loading...