Conditional Expectation and Variance
Conditional Expectation, Conditional Variance, and Probability Inequalities
Conditional expectation
A conditional distribution describes how a random variable behaves when another random variable is known. Since a conditional distribution is itself a valid probability distribution, its conditional expectation and conditional variance can be calculated.
Let X and Y be jointly distributed random variables.
Conditional expectation for continuous variables
If X and Y have joint density fX,Y(x,y) and marginal density fY(y), then, for values of y where fY(y)>0,
The conditional expectation of X given Y=y is
Conditional expectation for discrete variables
For discrete X and Y,
provided P(Y=y)>0.
The value of y is fixed when calculating E[X∣Y=y], but the result generally changes with y. Thus, E[X∣Y=y] is a function of y. When Y is treated as a random variable, this function becomes the random variable E[X∣Y].
If X and Y are independent, learning Y does not change the distribution of X, so
Example: two dice and their maximum
Let X and X1 be the results of two independent throws of a fair six-sided die. Each takes values 1,2,3,4,5,6, each with probability 61. Define
The pair (X,Y) is dependent: knowing the maximum restricts the possible value of X. For example, if Y=2, then X cannot be greater than 2.
Joint and marginal probabilities
For a fixed value y:
If x<y, the event X=x,Y=y requires X1=y. Its probability is 361.
If x=y, the event X=y,Y=y occurs whenever X1≤y. There are y possible values of X1, so its probability is 36y.
If x>y, the event is impossible.
Therefore, for y=1,…,6,
The marginal probabilities of Y are consequently
In contrast, the marginal distribution of X remains uniform:
The marginal probability of Y=y is obtained by summing the joint probabilities over all possible x: there are y−1 outcomes with x<y, each of probability 361, and one case with x=y, of probability 36y.
Conditional distribution of X given Y=y
For x<y,
For x=y,
Thus, conditional on the maximum being y, X can take values 1,…,y. The values below y each have conditional probability 2y−11, while the value y has probability 2y−1y.
Conditional expectation in the dice example
Using the conditional probabilities,
The resulting values are
These conditional expectations differ across values of Y, illustrating that E[X∣Y] is generally a random variable.
Law of total expectation
A central result about conditional expectation is that averaging the conditional expectation over the distribution of the conditioning variable recovers the original expectation:
This is also called the law of total expectation or the tower property.
For continuous variables, the equality follows by integrating over the joint density:
The discrete version follows by summing over the possible values of Y.
Applying the law to the dice example
In the dice example, the values of E[X∣Y] occur with the probabilities of the corresponding values of Y. Therefore,
Directly, X is uniform on {1,…,6}, so
The two calculations agree, as the law of total expectation requires.
The same result applies with the roles of X and Y reversed. In this example,
and hence E[E[Y∣X]]=E[Y]=36161.
Conditional variance and the law of total variance
The conditional variance measures the variability of X after the value of Y is known. It is defined by
Because both conditional moments depend on Y, conditional variance is generally also a random variable.
A key relationship is the law of total variance:
This separates the total variability in X into two components:
E[Var(X∣Y)] is the average variability remaining within the conditional distributions.
Var(E[X∣Y]) is the variability between the conditional means for different values of Y.
Derivation
The conditional variance identity gives
The variance of the conditional expectation is
Adding these expressions cancels the terms involving E[(E[X∣Y])2]. By the law of total expectation,
The sum therefore becomes
which proves the law of total variance.
Why probability inequalities are useful
Knowing a random variable’s expectation and variance does not usually determine its complete distribution. Different distributions can share the same mean and variance while having different shapes. However, expectation and variance can still provide bounds on the probability that a random variable is far from a chosen value or from its mean.
Chebyshev’s inequality gives a bound based on the second moment. Markov’s inequality provides a more general bound for nonnegative random variables or functions.
Chebyshev’s inequality
Let X have a finite expectation of (X−c)2, let c be any real number, and let ε>0. Then
The inequality bounds the probability that X is at least a distance ε from c.
Proof
On the event ∣X−c∣≥ε, squaring both sides gives
The quantity (X−c)2 is nonnegative everywhere. Thus, when its expectation is integrated over the whole sample space, the contribution from the event ∣X−c∣≥ε is at least the probability of that event:
Dividing by ε2 proves the inequality.
Chebyshev’s inequality around the mean
Taking c=μ=E[X] gives
If σ is the standard deviation of X and ε=kσ for k>0, then
This is a distribution-free bound: it applies whenever the variance exists, without requiring a specific distributional shape.
Example: a uniform random variable
Suppose X is uniform on [0,1]. Then
For k=2, Chebyshev’s inequality gives
Since 122=31≈0.577, while any value in [0,1] is at most 21 from its mean, the event is impossible. Its actual probability is 0. The bound 41 is valid but not tight in this case.
Markov’s inequality
Let h(X) be a nonnegative function of a random variable X, and suppose its expectation exists. For ε>0,
Proof
Let A be the event {h(X)≥ε}. Since h(X)≥0 everywhere, its expected value is at least its contribution on A. On A, h(X)≥ε, so
Dividing by ε gives Markov’s inequality.
Moment bound
For any r>0, choose h(X)=∣X∣r and ε=kr, where k>0. If E[∣X∣r] exists, Markov’s inequality yields
This bounds the probability that ∣X∣ exceeds a threshold using its rth absolute moment.
Chebyshev’s inequality as a consequence of Markov’s inequality
Choose
Then Markov’s inequality gives
Thus, Chebyshev’s inequality follows from Markov’s inequality by applying it to the squared deviation from the mean. Markov’s inequality is the more general result; Chebyshev’s inequality is a useful special case.

Ask anything
We've read this whole study set, so questions about it get the best answers.