9.2. Expectation by Conditioning#
Let
We will start with a simple example to illustrate the ideas.
See More
Let the joint distribution of
t = [3, 4]
s = [5, 6, 7]
pp = [0.1, 0.2, 0.3, 0.1, 0.2, 0.1]
jt_dist = Table().values('T', t, 'S', s).probabilities(pp)
jt_dist
T=3 | T=4 | |
---|---|---|
S=7 | 0.3 | 0.1 |
S=6 | 0.2 | 0.2 |
S=5 | 0.1 | 0.1 |
How can
Notice that to find
3*(0.3 + 0.2 + 0.1) + 4*(0.1 + 0.2 + 0.1)
3.4
This is equivalent to going to each cell of the table, weighting the value of
Let’s condition on
jt_dist.conditional_dist('T', 'S')
T=3 | T=4 | Sum | |
---|---|---|---|
Dist. of T | S=7 | 0.75 | 0.25 | 1.0 |
Dist. of T | S=6 | 0.50 | 0.50 | 1.0 |
Dist. of T | S=5 | 0.50 | 0.50 | 1.0 |
Marginal of T | 0.60 | 0.40 | 1.0 |
Each of the three conditional distributions is a distribution in its own right. Therefore its histogram has a balance point, just as the marginal distribution of
jt_dist.conditional_dist('T', 'S', show_ev=True)
T=3 | T=4 | Sum | EV | |
---|---|---|---|---|
Dist. of T | S=7 | 0.75 | 0.25 | 1.0 | 3.25 |
Dist. of T | S=6 | 0.50 | 0.50 | 1.0 | 3.50 |
Dist. of T | S=5 | 0.50 | 0.50 | 1.0 | 3.50 |
Marginal of T | 0.60 | 0.40 | 1.0 | 3.40 |
You can see
This defines a function of
ev_T_given_S = Table().with_columns(
's', s,
'E(T | S = s)', [3.5, 3.5, 3.25],
'P(S = s)', [0.2, 0.4, 0.4]
)
ev_T_given_S
s | E(T | S = s) | P(S = s) |
---|---|---|
5 | 3.5 | 0.2 |
6 | 3.5 | 0.4 |
7 | 3.25 | 0.4 |
This function of
As it’s a random variable, it has an expectation, which we can calculate using the non-linear function rule. The answer is a quantity that you will recognize.
ev = sum(ev_T_given_S.column('E(T | S = s)')*ev_T_given_S.column('P(S = s)'))
ev
3.4000000000000004
That’s right: it’s the expectation of
What we have learned from this is that
In short,
9.2.1. Conditional Expectation as a Random Variable#
In general, suppose
Then for each fixed value of
So for each
The key difference between expectation and conditional expectation:
, the expectation of , is a real number. , the conditional expectation of given , is a function of and hence is a random variable.
Quick Check
A class has three sections.
- Section 1 has 20 students with a midterm average of 75.
- Section 2 has 35 students with a midterm average of 70.
- Section 3 has 25 students with a midterm average of 85.
A student is picked at random from the class. Let
be the student’s section number. For example, is the event that the student is in Section 1. Let be the student’s midterm score. Draw a distribution table for .
Answer
The possible values of
See More
Since
9.2.2. Iterated Expectations#
Suppose we want the expectation of a random variable, and suppose it is easy for us to say what that expectation would be if we were given the value of a related random variable. The rule of iterated expectations says that we can find that conditional expectation first, and take its expectation to get our answer.
Formally, let
Proof:
Quick Check
A bag has three fair coins, five coins that land heads with chance
Answer
9.2.3. Example: Random Sums#
Let
Define the random sum
where
Notice that
Question: What is
Answer: If
First condition on a fixed value of
. Given , is the sum of i.i.d. terms. Hence
This is an equality of real numbers. Note that it is true for all
Next write the conditional expectation in random variable notation.
This is an equality of random variables.
Now use iterated expectations.
This is a natural answer. It is the expected number of terms being added times the expected size of each of those terms.
This is an important point to note about calculating expectations by conditioning. The natural answer is often correct.
9.2.4. Example: Population Size in a Branching Process#
In a Galton-Watson branching process, each individual has a random number of progeny. Assume that the numbers of progeny of the different indviduals are i.i.d. with mean
Question: Assuming that there are no deaths, what is the expected total number of individuals in Generations 0 through
Answer: Let
So by induction, for each
Indeed, the result is true for
The value of
This is closely related to the
9.2.5. Other Properties of Conditional Expectation#
The most important property of conditional expectation is the iteration that we have studied in this section. But conditional expectation has other properties that are analogous to those of expectation. They are now expressed as equalities of random variables instead of equalities of real numbers.
Go through the list and notice that all the moves you’d naturally want to make are justified. The proofs are routine; we won’t go through them.
Additivity.
Linear Transformation.
Two more properties formalize the idea that the variable that is given can be treated as a constant in conditional expectations.
“Constant”: Let
be a function. Then .“Pulling out a Constant”:
.
For example,
though we sincerely hope you won’t encounter a random variable as bizarre as this.