In probability theory, the conditional expectation, conditional expected value, or conditional mean of a random variable is its expected value – the value it would take “on average” over an arbitrarily large number of occurrences – given that a certain set of "conditions" is known to occur. If the random variable can take on only a finite number of values, the “conditions” are that the variable can only take on a subset of those values. More formally, in the case when the random variable is defined over a discrete probability space, the "conditions" are a partition of this probability space.
Depending on the context, the conditional expectation can be either a random variable or a function. The random variable is denoted analogously to conditional probability. The function form is either denoted or a separate function symbol such as is introduced with the meaning .
Examples
Example 1: Dice rolling
Consider the roll of a fair die and let A = 1 if the number is even (i.e., 2, 4, or 6) and A = 0 otherwise. Furthermore, let B = 1 if the number is prime (i.e., 2, 3, or 5) and B = 0 otherwise.
1
2
3
4
5
6
A
0
1
0
1
0
1
B
0
1
1
0
1
0
The unconditional expectation of A is , but the expectation of A conditional on B = 1 (i.e., conditional on the die roll being 2, 3, or 5) is , and the expectation of A conditional on B = 0 (i.e., conditional on the die roll being 1, 4, or 6) is . Likewise, the expectation of B conditional on A = 1 is , and the expectation of B conditional on A = 0 is .
Example 2: Rainfall data
Suppose we have daily rainfall data (mm of rain each day) collected by a weather station on every day of the ten–year (3652–day) period from January 1, 1990 to December 31, 1999. The unconditional expectation of rainfall for an unspecified day is the average of the rainfall amounts for those 3652 days. The conditional expectation of rainfall for an otherwise unspecified day known to be (conditional on being) in the month of March, is the average of daily rainfall over all 310 days of the ten–year period that falls in March. And the conditional expectation of rainfall conditional on days dated March 2 is the average of the rainfall amounts that occurred on the ten days with that specific date.
Note that conditioning on a discrete random variable is the same as conditioning on the corresponding event:
where A is the set .
Continuous random variables
Let and be continuous random variables with joint density
's density
and conditional density of given the event
The conditional expectation of given is
When the denominator is zero, the expression is undefined.
Note that conditioning on a continuous random variable is not the same as conditioning on the event as it was in the discrete case. For a discussion, see Conditioning on an event of probability zero. Not respecting this distinction can lead to contradictory conclusions as illustrated by the Borel-Kolmogorov paradox.
In what follows let be a probability space, and in
with mean and variance.
The expectation minimizes the mean squared error:
.
The conditional expectation of X is defined analogously, except instead of a single number
, the result will be a function . Let be a random vector. The conditional expectation is a measurable function such that
.
Note that unlike , the conditional expectation is not generally unique: there may be multiple minimizers of the mean squared error.
Uniqueness
Example 1: Consider the case where Y is the constant random variable that's always 1.
Then the mean squared error is minimized by any function of the form
Example 2: Consider the case where Y is the 2-dimensional random vector . Then clearly
but in terms of functions it can be expressed as or or infinitely many other ways. In the context of linear regression, this lack of uniqueness is called multicollinearity.
Conditional expectation is unique up to a set of measure zero in . The measure used is the pushforward measure induced by Y.
In the first example, the pushforward measure is a Dirac distribution at 1. In the second it is concentrated on the "diagonal" , so that any set not intersecting it has measure 0.
Existence
The existence of a minimizer for is non-trivial. It can be shown that
is a closed subspace of the Hilbert space .[6]
By the Hilbert projection theorem, the necessary and sufficient condition for
to be a minimizer is that for all in M we have
.
In words, this equation says that the residual is orthogonal to the space M of all functions of Y.
This orthogonality condition, applied to the indicator functions,
is used below to extend conditional expectation to the case that X and Y are not necessarily in .
Connections to regression
The conditional expectation is often approximated in applied mathematics and statistics due to the difficulties in analytically calculating it, and for interpolation.[7]
The Hilbert subspace
defined above is replaced with subsets thereof by restricting the functional form of g, rather than allowing any measureable function. Examples of this are decision tree regression when g is required to be a simple function, linear regression when g is required to be affine, etc.
These generalizations of conditional expectation come at the cost of many of its properties no longer holding.
For example, let M
be the space of all linear functions of Y and let denote this generalized conditional expectation/ projection. If does not contain the constant functions, the tower property
will not hold.
An important special case is when X and Y are jointly normally distributed. In this case
it can be shown that the conditional expectation is equivalent to linear regression:
Since is a sub -algebra of , the function is usually not -measurable, thus the existence of the integrals of the form , where and is the restriction of to , cannot be stated in general. However, the local averages can be recovered in with the help of the conditional expectation.
A conditional expectation of X given , denoted as , is any -measurable function which satisfies:
As noted in the discussion, this condition is equivalent to saying that the residual is orthogonal to the indicator functions :
Existence
The existence of can be established by noting that for is a finite measure on that is absolutely continuous with respect to . If is the natural injection from to , then is the restriction of to and is the restriction of to . Furthermore, is absolutely continuous with respect to , because the condition
This is not a constructive definition; we are merely given the required property that a conditional expectation must satisfy.
The definition of may resemble that of for an event but these are very different objects. The former is a -measurable function , while the latter is an element of and for .
Uniqueness can be shown to be almost sure: that is, versions of the same conditional expectation will only differ on a set of probability zero.
The σ-algebra controls the "granularity" of the conditioning. A conditional expectation over a finer (larger) σ-algebra retains information about the probabilities of a larger class of events. A conditional expectation over a coarser (smaller) σ-algebra averages over more events.
Conditional variance: Using the conditional expectation we can define, by analogy with the definition of the variance as the mean square deviation from the average, the conditional variance
Martingale convergence: For a random variable , that has finite expectation, we have , if either is an increasing series of sub-σ-algebras and or if is a decreasing series of sub-σ-algebras and .
Conditional expectation as -projection: If are in the Hilbert space of square-integrable real random variables (real random variables with finite second moment) then
for -measurable , we have , i.e. the conditional expectation is in the sense of the L2(P) scalar product the orthogonal projection from to the linear subspace of -measurable functions. (This allows to define and prove the existence of the conditional expectation based on the Hilbert projection theorem.)