In
probability theory
Probability theory is the branch of mathematics concerned with probability. Although there are several different probability interpretations, probability theory treats the concept in a rigorous mathematical manner by expressing it through a set o ...
, the conditional expectation, conditional expected value, or conditional mean of a
random variable
A random variable (also called random quantity, aleatory variable, or stochastic variable) is a mathematical formalization of a quantity or object which depends on random events. It is a mapping or a function from possible outcomes (e.g., the p ...
is its
expected value
In probability theory, the expected value (also called expectation, expectancy, mathematical expectation, mean, average, or first moment) is a generalization of the weighted average. Informally, the expected value is the arithmetic mean of a ...
– 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
In probability theory, a probability space or a probability triple (\Omega, \mathcal, P) is a mathematical construct that provides a formal model of a random process or "experiment". For example, one can define a probability space which models t ...
, 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
In probability theory, conditional probability is a measure of the probability of an event occurring, given that another event (by assumption, presumption, assertion or evidence) has already occurred. This particular method relies on event B occu ...
. 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 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.
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.
History
The related concept of
conditional probability
In probability theory, conditional probability is a measure of the probability of an event occurring, given that another event (by assumption, presumption, assertion or evidence) has already occurred. This particular method relies on event B occu ...
dates back at least to
Laplace, who calculated conditional distributions. It was
Andrey Kolmogorov
Andrey Nikolaevich Kolmogorov ( rus, Андре́й Никола́евич Колмого́ров, p=ɐnˈdrʲej nʲɪkɐˈlajɪvʲɪtɕ kəlmɐˈɡorəf, a=Ru-Andrey Nikolaevich Kolmogorov.ogg, 25 April 1903 – 20 October 1987) was a Sovi ...
who, in 1933, formalized it using the
Radon–Nikodym theorem.
In works of
Paul Halmos
Paul Richard Halmos ( hu, Halmos Pál; March 3, 1916 – October 2, 2006) was a Hungarian-born American mathematician and statistician who made fundamental advances in the areas of mathematical logic, probability theory, statistics, operat ...
and
Joseph L. Doob from 1953, conditional expectation was generalized to its modern definition using
sub-σ-algebras.
Definitions
Conditioning on an event
If is an event in
with nonzero probability,
and is a
discrete random variable
A random variable (also called random quantity, aleatory variable, or stochastic variable) is a mathematical formalization of a quantity or object which depends on random events. It is a mapping or a function from possible outcomes (e.g., the po ...
, the conditional expectation
of given is
:
where the sum is taken over all possible outcomes of .
Note that if
, the conditional expectation is undefined due to the division by zero.
Discrete random variables
If and are
discrete random variables,
the conditional expectation of given is
:
where
is the
joint probability mass function of and . The sum is taken over all possible outcomes of .
Note that conditioning on a discrete random variable is the same as conditioning on the corresponding event:
:
where is the set
.
Continuous random variables
Let
and
be
continuous random variables
In probability theory and statistics, a probability distribution is the mathematical function that gives the probabilities of occurrence of different possible outcomes for an experiment. It is a mathematical description of a random phenomenon i ...
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.
L2 random variables
All random variables in this section are assumed to be in
, that is
square integrable.
In its full generality, conditional expectation is developed without this assumption, see below under
Conditional expectation with respect to a sub-σ-algebra. The
theory is, however, considered more intuitive and admits
important generalizations.
In the context of
random variables, conditional expectation is also called
regression
Regression or regressions may refer to:
Science
* Marine regression, coastal advance due to falling sea level, the opposite of marine transgression
* Regression (medicine), a characteristic of diseases to express lighter symptoms or less extent ( ...
.
In what follows let
be a probability space, and
in
with mean
and
variance
In probability theory and statistics, variance is the expectation of the squared deviation of a random variable from its population mean or sample mean. Variance is a measure of dispersion, meaning it is a measure of how far a set of number ...
.
The expectation
minimizes the
mean squared error
In statistics, the mean squared error (MSE) or mean squared deviation (MSD) of an estimator (of a procedure for estimating an unobserved quantity) measures the average of the squares of the errors—that is, the average squared difference betwe ...
:
:
.
The conditional expectation of 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 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 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
In statistics, linear regression is a linear approach for modelling the relationship between a scalar response and one or more explanatory variables (also known as dependent and independent variables). The case of one explanatory variable is ...
, 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 .
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
.
By the
Hilbert projection theorem, the necessary and sufficient condition for
to be a minimizer is that for all
in we have
:
.
In words, this equation says that the
residual is orthogonal to the space of all functions of .
This orthogonality condition, applied to the
indicator functions ,
is used below to extend conditional expectation to the case that and are not necessarily in
.
Connections to regression
The conditional expectation is often approximated in
applied mathematics
Applied mathematics is the application of mathematical methods by different fields such as physics, engineering, medicine, biology, finance, business, computer science, and industry. Thus, applied mathematics is a combination of mathemat ...
and
statistics due to the difficulties in analytically calculating it, and for interpolation.
The Hilbert subspace
:
defined above is replaced with subsets thereof by restricting the functional form of , rather than allowing any measureable function. Examples of this are
decision tree regression when is required to be a
simple function,
linear regression
In statistics, linear regression is a linear approach for modelling the relationship between a scalar response and one or more explanatory variables (also known as dependent and independent variables). The case of one explanatory variable is ...
when 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
be the space of all linear functions of and let
denote this generalized conditional expectation/
projection. If
does not contain the
constant functions, the
tower property
The proposition in probability theory known as the law of total expectation, the law of iterated expectations (LIE), Adam's law, the tower rule, and the smoothing theorem, among other names, states that if X is a random variable whose expected v ...
will not hold.
An important special case is when and are jointly normally distributed. In this case
it can be shown that the conditional expectation is equivalent to linear regression:
:
for coefficients
described in
Multivariate normal distribution#Conditional distributions.
Conditional expectation with respect to a sub-σ-algebra

Consider the following:
*
is a
probability space
In probability theory, a probability space or a probability triple (\Omega, \mathcal, P) is a mathematical construct that provides a formal model of a random process or "experiment". For example, one can define a probability space which models t ...
.
*
is a
random variable
A random variable (also called random quantity, aleatory variable, or stochastic variable) is a mathematical formalization of a quantity or object which depends on random events. It is a mapping or a function from possible outcomes (e.g., the p ...
on that probability space with finite expectation.
*
is a sub-
σ-algebra of
.
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
In mathematics and in particular measure theory, a measurable function is a function between the underlying sets of two measurable spaces that preserves the structure of the spaces: the preimage of any measurable set is measurable. This is i ...
which satisfies:
:
for each
.
[
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
In mathematics, if A is a subset of B, then the inclusion map (also inclusion function, insertion, or canonical injection) is the function \iota that sends each element x of A to x, treated as an element of B:
\iota : A\rightarrow B, \qquad \iota ...
from to , then is the restriction of to and is the restriction of to . Furthermore, is absolutely continuous with respect to , because the condition
:
implies
:
Thus, we have
:
where the derivatives are Radon–Nikodym derivatives of measures.
Conditional expectation with respect to a random variable
Consider, in addition to the above,
* A measurable space , and
* A random variable .
The conditional expectation of given is defined by applying the above construction on the σ-algebra generated by :
: