Post · 7 min read· pp. 187–191
Video Available 
If you have a collection of numbers a1,a2,...,aN, their average is a single number that describes
the whole collection. Now, consider a random variable X. We would like to define its average, or as
it is called in probability, its expected value or mean. The expected value is defined
as the weighted average of the values in the range.
Expected value (= mean=average):
Definition
Let X be a discrete random variable with range RX={x1,x2,x3,...} (finite or countably infinite).
The expected value of X, denoted by EX is defined as
EX=xk∈RX∑xkP(X=xk)=xk∈RX∑xkPX(xk).
To understand the concept behind EX, consider a discrete random variable with range RX={x1,x2,x3,...}.
This random variable is a result of random experiment. Suppose that we repeat this experiment a very
large number of times N, and that the trials are independent. Let N1 be the number of times we
observe x1, N2 be the number of times we observe x2, ...., Nk be the number of times we
observe xk, and so on. Since P(X=xk)=PX(xk), we expect that
PX(x1)≈NN1,
PX(x2)≈NN2,
...
PX(xk)≈NNk,
...
In other words, we have
Nk≈NPX(xk). Now, if we take the average of the observed values
of
X, we obtain
| |
|---|
| Average | =NN1x1+N2x2+N3x3+... |
| ≈Nx1NPX(x1)+x2NPX(x2)+x3NPX(x3)+... |
| =x1PX(x1)+x2PX(x2)+x3PX(x3)+... |
| =EX. |
Thus, the intuition behind EX is that if you repeat the random experiment independently N times
and take the average of the observed data, the average gets closer and closer to EX as N gets
larger and larger. We sometimes denote EX by μX.
Different notations for expected value of X: EX=E[X]=E(X)=μX.
Let's compute the expected values of some well-known distributions.
Example
Let X∼Bernoulli(p). Find EX.
- Solution
For the Bernoulli distribution, the range of X is RX={0,1}, and PX(1)=p
and PX(0)=1−p. Thus,
| |
|---|
| EX | =0⋅PX(0)+1⋅PX(1) |
| =0⋅(1−p)+1⋅p |
| =p. |
For a Bernoulli random variable, finding the expectation EX was easy. However, for some random variables,
to find the expectation sum, you might need a little algebra. Let's look at another example.
Example
Let X∼Geometric(p). Find EX.
- Solution
For the geometric distribution, the range is RX={1,2,3,...} and the PMF is given by
PX(k)=qk−1p, for k=1,2,...
where, $0 < p < 1$ and q=1−p. Thus, we can write
| |
|---|
| EX | =∑xk∈RXxkPX(xk) |
| =∑k=1∞kqk−1p |
| =p∑k=1∞kqk−1. |
Now, we already know the geometric sum formula
k=0∑∞xk=1−x1, for ∣x∣<1.
But we need to find a sum ∑k=1∞kqk−1. Luckily, we can convert the geometric
sum to the form we want by taking derivative with respect to x, i.e.,
dxdk=0∑∞xk=dxd1−x1, for ∣x∣<1.
Thus, we have
k=0∑∞kxk−1=(1−x)21, for ∣x∣<1.
To finish finding the expectation, we can write
| |
|---|
| EX | =p∑k=1∞kqk−1 |
| =p(1−q)21 |
| =pp21 |
| =p1. |
So, for X∼Geometric(p), EX=p1. Note that this makes sense intuitively.
The random experiment behind the geometric distribution was that we tossed a coin until
we observed the first heads, where P(H)=p. Here, we found out that on average you need
to toss the coin p1 times in this experiment. In particular, if p is small
(heads are unlikely), then p1 is large, so you need to toss the coin a large
number of times before you observe a heads. Conversely, for large p a few coin tosses
usually suffices.
Example
Let X∼Poisson(λ). Find EX.
- Solution
Before doing the math, we suggest that you try to guess what the expected value would be.
It might be a good idea to think about the examples where the Poisson distribution is used. For
the Poisson distribution, the range is RX={0,1,2,⋯} and the PMF is given by
PX(k)=k!e−λλk, for k=0,1,2,...
Thus, we can write
| | |
|---|
| EX | =∑xk∈RXxkPX(xk) | |
| =∑k=0∞kk!e−λλk | |
| =e−λ∑k=1∞(k−1)!λk | |
| =e−λ∑j=0∞j!λ(j+1) | ( by letting j=k−1) |
| =λe−λ∑j=0∞j!λj | |
| =λe−λeλ | ( Taylor series for eλ) |
| =λ. | |
So the expected value is λ. Remember, when we first talked about the Poisson distribution,
we introduced its parameter λ as the average number of events. So it is not surprising
that the expected value is EX=λ.
Before looking at more examples, we would like to talk about an important property of expectation,
which is linearity. Note that if X is a random variable, any function of X is also a random
variable, so we can talk about its expected value. For example, if Y=aX+b, we can talk about EY=E[aX+b].
Or if you define Y=X1+X2+⋯+Xn, where Xi's are random variables, we can talk about
EY=E[X1+X2+⋯+Xn]. The following theorem states that expectation is linear, which makes it
easier to calculate the expected value of linear functions of random variables.
Expectation is linear:
Theorem
We have
- E[aX+b]=aEX+b, for all a,b∈R;
- E[X1+X2+⋯+Xn]=EX1+EX2+⋯+EXn, for any set of random variables X1,X2,⋯,Xn.
We will prove this theorem later on in Chapter 5, but here we would like to emphasize its
importance with an example.
Example
Let X∼Binomial(n,p). Find EX.
- Solution
We provide two ways to solve this problem. One way is as before: we do the math and
calculate EX=∑xk∈RXxkPX(xk) which will be a little tedious. A much
faster way would be to use linearity of expectation. In particular, remember that if
X1,X2,...,Xn are independent Bernoulli(p) random variables, then the random
variable X defined by X=X1+X2+...+Xn has a Binomial(n,p) distribution. Thus,
we can write
| | |
|---|
| EX | =E[X1+X2+⋯+Xn] | |
| =EX1+EX2+⋯+EXn | by linearity of expectation |
| =p+p+⋯+p | |
| =np. | |
We will provide the direct calculation of EX=∑xk∈RXxkPX(xk) in the Solved
Problems section and as you will see it needs a lot more algebra than above. The bottom line
is that linearity of expectation can sometimes make our calculations much easier. Let's look
at another example.
Example
Let X∼Pascal(m,p). Find EX. (Hint: Try to write X=X1+X2+⋯+Xm,
such that you already know EXi.)
- Solution
We claim that if the Xi's are independent and Xi∼Geometric(p), for i=1, $2$, ⋯,
m, then the random variable X defined by X=X1+X2+⋯+Xm has Pascal(m,p). To see
this, you can look at
Problem 5 in Section 3.1.6
and the discussion there. Now, since we already know EXi=p1, we conclude
| | |
|---|
| EX | =E[X1+X2+⋯+Xm] | |
| =EX1+EX2+⋯+EXm | by linearity of expectation |
| =p1+p1+⋯+p1 | |
| =pm. | |
Again, you can try to find EX directly and as you will see, you need much more algebra
compared to using the linearity of expectation.