# Conditioning (probability)

Main Article
Discussion
Related Articles  [?]
Bibliography  [?]
Citable Version  [?]

This editable Main Article is under development and subject to a disclaimer.

Beliefs depend on the available information. This idea is formalized in probability theory by conditioning. Conditional probabilities, conditional expectations and conditional distributions are treated on three levels: discrete probabilities, probability density functions, and measure theory. Conditioning leads to a non-random result if the condition is completely specified; otherwise, if the condition is left random, the result of conditioning is also random.

This article concentrates on interrelations between various kinds of conditioning, shown mostly by examples.

## Conditioning on the discrete level

Example. A fair coin is tossed 10 times; the random variable ${\displaystyle X}$ is the number of heads in these 10 tosses, and ${\displaystyle Y}$ — the number of heads in the first 3 tosses. In spite of the fact that ${\displaystyle Y}$ emerges before ${\displaystyle X}$ it may happen that someone knows ${\displaystyle X}$ but not ${\displaystyle Y}$.

### Conditional probability

Given that ${\displaystyle X=1,}$ the conditional probability of the event ${\displaystyle Y=0}$ is ${\displaystyle P(Y=0|X=1)=P(Y=0,X=1)/P(X=1)=0.7.}$ More generally,

${\displaystyle \mathbb {P} (Y=0|X=x)={\frac {\binom {7}{x}}{\binom {10}{x}}}={\frac {7!(10-x)!}{(7-x)!10!}}}$

for ${\displaystyle x=0,1,2,3,4,5,6,7;}$ otherwise (for ${\displaystyle x=8,9,10}$), ${\displaystyle P(Y=0|X=x)=0.}$ One may also treat the conditional probability as a random variable, — a function of the random variable ${\displaystyle X}$, namely,

${\displaystyle \mathbb {P} (Y=0|X)={\begin{cases}{\binom {7}{X}}/{\binom {10}{X}}&{\text{for }}X\leq 7,\\0&{\text{for }}X>7.\end{cases}}}$

The expectation of this random variable is equal to the (unconditional) probability,

${\displaystyle \mathbb {E} (\mathbb {P} (Y=0|X))=\sum _{x}\mathbb {P} (Y=0|X=x)\mathbb {P} (X=x)=\mathbb {P} (Y=0),}$

namely,

${\displaystyle \sum _{x=0}^{7}{\frac {\binom {7}{x}}{\binom {10}{x}}}\cdot {\frac {1}{2^{10}}}{\binom {10}{x}}={\frac {1}{8}},}$

which is an instance of the law of total probability ${\displaystyle E(P(A|X))=P(A).}$

Thus, ${\displaystyle P(Y=0|X=1)}$ may be treated as the value of the random variable ${\displaystyle P(Y=0|X)}$ corresponding to ${\displaystyle X=1.}$ On the other hand, ${\displaystyle P(Y=0|X=1)}$ is well-defined irrespective of other possible values of ${\displaystyle X}$.

### Conditional expectation

Given that ${\displaystyle X=1,}$ the conditional expectation of the random variable ${\displaystyle Y}$ is ${\displaystyle E(Y|X=1)=0.3.}$ More generally,

${\displaystyle \mathbb {E} (Y|X=x)={\frac {3}{10}}x}$

for ${\displaystyle x=0,...,10.}$ (In this example it appears to be a linear function, but in general it is nonlinear.) One may also treat the conditional expectation as a random variable, — a function of the random variable ${\displaystyle X}$, namely,

${\displaystyle \mathbb {E} (Y|X)={\frac {3}{10}}X.}$

The expectation of this random variable is equal to the (unconditional) expectation of ${\displaystyle Y}$,

${\displaystyle \mathbb {E} (\mathbb {E} (Y|X))=\sum _{x}\mathbb {E} (Y|X=x)\mathbb {P} (X=x)=\mathbb {E} (Y),}$

namely,

${\displaystyle \sum _{x=0}^{10}{\frac {3}{10}}x\cdot {\frac {1}{2^{10}}}{\binom {10}{x}}={\frac {3}{2}}\,,}$   or simply   ${\displaystyle \mathbb {E} {\Big (}{\frac {3}{10}}X{\Big )}={\frac {3}{10}}\mathbb {E} (X)={\frac {3}{10}}\cdot 5={\frac {3}{2}}\,,}$

which is an instance of the law of total expectation ${\displaystyle E(E(Y|X))=E(Y).}$

The random variable ${\displaystyle E(Y|X)}$ is the best predictor of ${\displaystyle Y}$ given ${\displaystyle X}$. That is, it minimizes the mean square error ${\displaystyle E(Y-f(X))^{2}}$ on the class of all random variables of the form ${\displaystyle f(X).}$ This class of random variables remains intact if ${\displaystyle X}$ is replaced, say, with ${\displaystyle 2X.}$ Thus, ${\displaystyle E(Y|2X)=E(Y|X).}$ It does not mean that ${\displaystyle E(Y|2X)=0.3\cdot 2X;}$ rather, ${\displaystyle E(Y|2X)=0.15\cdot 2X=0.3X.}$ In particular, ${\displaystyle E(Y|2X=2)=0.3.}$ More generally, ${\displaystyle E(Y|g(X))=E(Y|X)}$ for every function ${\displaystyle g}$ that is one-to-one on the set of all possible values of ${\displaystyle X}$. The values of ${\displaystyle X}$ are irrelevant; what matters is the partition (denote it α${\displaystyle X}$)

${\displaystyle \Omega =\{X=x_{1}\}\uplus \{X=x_{2}\}\uplus \dots }$

of the sample space ${\displaystyle \Omega }$ into disjoint sets ${\displaystyle \{X=x_{n}\}.}$ (Here ${\displaystyle x_{1},x_{2},\dots }$ are all possible values of ${\displaystyle X}$.) Given an arbitrary partition ${\displaystyle \alpha }$ of ${\displaystyle \Omega }$, one may define the random variable ${\displaystyle E(Y|\alpha ).}$ Still, ${\displaystyle E(E(Y|\alpha ))=E(Y).}$

Conditional probability may be treated as a special case of conditional expectation. Namely, ${\displaystyle P(A|X)=E(Y|X)}$ if ${\displaystyle Y}$ is the indicator of ${\displaystyle A}$. Therefore the conditional probability also depends on the partition ${\displaystyle \alpha _{X}}$ generated by ${\displaystyle X}$ rather than on ${\displaystyle X}$ itself; ${\displaystyle P(A|g(X))=P(A|X)=P(A|\alpha ),}$ ${\displaystyle \alpha =\alpha _{X}=\alpha _{g(X)}.}$

On the other hand, conditioning on an event ${\displaystyle B}$ is well-defined, provided that ${\displaystyle P(B)\neq 0,}$ irrespective of any partition that may contain ${\displaystyle B}$ as one of several parts.

### Conditional distribution

Given ${\displaystyle X=x,}$ the conditional distribution of ${\displaystyle Y}$ is

${\displaystyle \mathbb {P} (Y=y|X=x)={\frac {{\binom {3}{y}}{\binom {7}{x-y}}}{\binom {10}{x}}}={\frac {{\binom {x}{y}}{\binom {10-x}{3-y}}}{\binom {10}{3}}}}$

for ${\displaystyle 0\leq y\leq min(3,x).}$ It is the hypergeometric distribution ${\displaystyle \mathrm {H} (x;3,7),}$ or equivalently, ${\displaystyle \mathrm {H} (3;x,10-x).}$ The corresponding expectation ${\displaystyle 0.3x,}$ obtained from the general formula ${\displaystyle n{\frac {R}{R+W}}}$ for ${\displaystyle H(n;R,W),}$ is nothing but the conditional expectation ${\displaystyle E(Y|X=x)=0.3x.}$

Treating ${\displaystyle H(X;3,7)}$ as a random distribution (a random vector in the four-dimensional space of all measures on ${\displaystyle \{0,1,2,3\}),}$ one may take its expectation, getting the unconditional distribution of ${\displaystyle Y}$, — the binomial distribution ${\displaystyle \mathrm {Bin} (3,0.5).}$ This fact amounts to the equality

${\displaystyle \sum _{x=0}^{10}\mathbb {P} (Y=y|X=x)\mathbb {P} (X=x)=\mathbb {P} (Y=y)={\frac {1}{2^{3}}}{\binom {3}{y}}}$

for ${\displaystyle y=0,1,2,3;}$ just the law of total probability.

## Conditioning on the level of densities

Example. A point of the sphere ${\displaystyle x^{2}+y^{2}+z^{2}=1}$ is chosen at random according to the uniform distribution on the sphere. The random variables ${\displaystyle X}$, ${\displaystyle Y}$, ${\displaystyle Z}$ are the coordinates of the random point. The joint density of ${\displaystyle X}$, ${\displaystyle Y}$, ${\displaystyle Z}$ does not exist (since the sphere is of zero volume), but the joint density ${\displaystyle f_{X,Y}}$ of ${\displaystyle X}$, ${\displaystyle Y}$ exists,

${\displaystyle f_{X,Y}(x,y)={\begin{cases}{\frac {1}{2\pi {\sqrt {1-x^{2}-y^{2}}}}}&{\text{if }}x^{2}+y^{2}<1,\\0&{\text{otherwise}}.\end{cases}}}$

(The density is non-constant because of a non-constant angle between the sphere and the plane.) The density of ${\displaystyle X}$ may be calculated by integration,

${\displaystyle f_{X}(x)=\int _{-\infty }^{+\infty }f_{X,Y}(x,y)\,\mathrm {d} y=\int _{-{\sqrt {1-x^{2}}}}^{+{\sqrt {1-x^{2}}}}{\frac {\mathrm {d} y}{2\pi {\sqrt {1-x^{2}-y^{2}}}}}\,;}$

surprisingly, the result does not depend on ${\displaystyle x}$ in (-1,1),

${\displaystyle f_{X}(x)={\begin{cases}0.5&{\text{for }}-1

which means that ${\displaystyle X}$ is distributed uniformly on ${\displaystyle (-1,1).}$ The same holds for ${\displaystyle Y}$ and ${\displaystyle Z}$ (and in fact, for ${\displaystyle aX+bY+cZ}$ whenever ${\displaystyle a^{2}+b^{2}+c^{2}=1).}$

### Conditional probability

#### Calculation

Given that ${\displaystyle X=0.5,}$ the conditional probability of the event ${\displaystyle Y\leq 0.75}$ is the integral of the conditional density,

{\displaystyle {\begin{aligned}&f_{Y|X=0.5}(y)={\frac {f_{X,Y}(0.5,y)}{f_{X}(0.5)}}={\begin{cases}{\frac {1}{\pi {\sqrt {0.75-y^{2}}}}}&{\text{for }}-{\sqrt {0.75}}

More generally,

${\displaystyle \mathbb {P} (Y\leq y|X=x)={\frac {1}{2}}+{\frac {1}{\pi }}\arcsin {\frac {y}{\sqrt {1-x^{2}}}}}$

for all ${\displaystyle x}$ and ${\displaystyle y}$ such that ${\displaystyle -1 (otherwise the denominator ${\displaystyle f_{X}(x)}$ vanishes) and ${\displaystyle \textstyle -{\sqrt {1-x^{2}}} (otherwise the conditional probability degenerates to 0 or 1). One may also treat the conditional probability as a random variable, — a function of the random variable ${\displaystyle X}$, namely,

${\displaystyle \mathbb {P} (Y\leq y|X)={\begin{cases}0&{\text{for }}X^{2}\geq 1-y^{2}{\text{ and }}y<0,\\{\frac {1}{2}}+{\frac {1}{\pi }}\arcsin {\frac {y}{\sqrt {1-X^{2}}}}&{\text{for }}X^{2}<1-y^{2},\\1&{\text{for }}X^{2}\geq 1-y^{2}{\text{ and }}y>0.\end{cases}}}$

The expectation of this random variable is equal to the (unconditional) probability,

${\displaystyle \mathbb {E} (\mathbb {P} (Y\leq y|X))=\int _{-\infty }^{+\infty }\mathbb {P} (Y\leq y|X=x)f_{X}(x)\,\mathrm {d} x=\mathbb {P} (Y\leq y),}$

which is an instance of the law of total probability ${\displaystyle E(P(A|X))=P(A).}$

#### Interpretation

The conditional probability ${\displaystyle P(Y\leq 0.75|X=0.5)}$ cannot be interpreted as ${\displaystyle P(Y\leq 0.75,X=0.5)/P(X=0.5),}$ since the latter gives 0/0. Accordingly, ${\displaystyle P(Y\leq 0.75|X=0.5)}$ cannot be interpreted via empirical frequencies, since the exact value ${\displaystyle X=0.5}$ has no chance to appear at random, not even once during an infinite sequence of independent trials.

The conditional probability can be interpreted as a limit,

{\displaystyle {\begin{aligned}&\mathbb {P} (Y\leq 0.75|X=0.5)=\lim _{\varepsilon \to 0+}\mathbb {P} (Y\leq 0.75|0.5-\varepsilon

### Conditional expectation

The conditional expectation ${\displaystyle E(Y|X=0.5)}$ is of little interest; it vanishes just by symmetry. It is more interesting to calculate ${\displaystyle E(|Z||X=0.5)}$ treating |${\displaystyle Z}$| as a function of ${\displaystyle X}$, ${\displaystyle Y}$:

{\displaystyle {\begin{aligned}&|Z|=h(X,Y)={\sqrt {1-X^{2}-Y^{2}}}\,;\\&\mathrm {E} (|Z||X=0.5)=\int _{-\infty }^{+\infty }h(0.5,y)f_{Y|X=0.5}(y)\,\mathrm {d} y=\\&=\int _{-{\sqrt {0.75}}}^{+{\sqrt {0.75}}}{\sqrt {0.75-y^{2}}}\cdot {\frac {\mathrm {d} y}{\pi {\sqrt {0.75-y^{2}}}}}={\frac {2}{\pi }}{\sqrt {0.75}}\,.\end{aligned}}}

More generally,

${\displaystyle \mathbb {E} (|Z||X=x)={\frac {2}{\pi }}{\sqrt {1-x^{2}}}}$

for ${\displaystyle -1 One may also treat the conditional expectation as a random variable, — a function of the random variable X, namely,

${\displaystyle \mathbb {E} (|Z||X)={\frac {2}{\pi }}{\sqrt {1-X^{2}}}\,.}$

The expectation of this random variable is equal to the (unconditional) expectation of ${\displaystyle |Z|,}$

${\displaystyle \mathbb {E} (\mathbb {E} (|Z||X))=\int _{-\infty }^{+\infty }\mathbb {E} (|Z||X=x)f_{X}(x)\,\mathrm {d} x=\mathbb {E} (|Z|)\,,}$

namely,

${\displaystyle \int _{-1}^{+1}{\frac {2}{\pi }}{\sqrt {1-x^{2}}}\cdot {\frac {\mathrm {d} x}{2}}={\frac {1}{2}}\,,}$

which is an instance of the law of total expectation ${\displaystyle E(E(Y|X))=E(Y).}$

The random variable ${\displaystyle E(|Z||X)}$ is the best predictor of ${\displaystyle |Z|}$ given ${\displaystyle X}$. That is, it minimizes the mean square error ${\displaystyle E(|Z|-f(X))^{2}}$ on the class of all random variables of the form ${\displaystyle f(X).}$ Similarly to the discrete case, ${\displaystyle E(|Z||g(X))=E(|Z||X)}$ for every measurable function ${\displaystyle g}$ that is one-to-one on ${\displaystyle (-1,1).}$

### Conditional distribution

Given ${\displaystyle X=x,}$ the conditional distribution of ${\displaystyle Y}$, given by the density ${\displaystyle f_{Y|X=x}(y),}$ is the (rescaled) arcsin distribution; its cumulative distribution function is

${\displaystyle F_{Y|X=x}(y)=\mathbb {P} (Y\leq y|X=x)={\frac {1}{2}}+{\frac {1}{\pi }}\arcsin {\frac {y}{\sqrt {1-x^{2}}}}}$

for all ${\displaystyle x}$ and ${\displaystyle y}$ such that ${\displaystyle x^{2}+y^{2}<1.}$ The corresponding expectation of ${\displaystyle h(x,Y)}$ is nothing but the conditional expectation ${\displaystyle E(h(X,Y)|X=x).}$ The mixture of these conditional distributions, taken for all ${\displaystyle x}$ (according to the distribution of ${\displaystyle X}$) is the unconditional distribution of ${\displaystyle Y}$. This fact amounts to the equalities

{\displaystyle {\begin{aligned}&\int _{-\infty }^{+\infty }f_{Y|X=x}(y)f_{X}(x)\,\mathrm {d} x=f_{Y}(y)\,,\\&\int _{-\infty }^{+\infty }F_{Y|X=x}(y)f_{X}(x)\,\mathrm {d} x=F_{Y}(y)\,,\end{aligned}}}

the latter being the instance of the law of total probability mentioned above.

## What conditioning is not

On the discrete level conditioning is possible only if the condition is of nonzero probability (one cannot divide by zero). On the level of densities, conditioning on ${\displaystyle X=x}$ is possible even though ${\displaystyle P(X=x)=0.}$ This success may create the illusion that conditioning is always possible. Regretfully, it is not, for several reasons presented below.

### Geometric intuition: caution

The result ${\displaystyle P(Y\leq 0.75|X=0.5)=5/6,}$ mentioned above, is geometrically evident in the following sense. The points ${\displaystyle (x,y,z)}$ of the sphere ${\displaystyle x^{2}+y^{2}+z^{2}=1,}$ satisfying the condition ${\displaystyle x=0.5,}$ are a circle ${\displaystyle y^{2}+z^{2}=0.75}$ of radius ${\displaystyle {\sqrt {0.75}}}$ on the plane ${\displaystyle x=0.5.}$ The inequality ${\displaystyle y\leq 0.75}$ holds on an arc. The length of the arc is 5/6 of the length of the circle, which is why the conditional probability is equal to 5/6.

This successful geometric explanation may create the illusion that the following question is trivial.

A point of a given sphere is chosen at random (uniformly). Given that the point lies on a given plane, what is its conditional distribution?

It may seem evident that the conditional distribution must be uniform on the given circle (the intersection of the given sphere and the given plane). Sometimes it really is, but in general it is not. Especially, ${\displaystyle Z}$ is distributed uniformly on ${\displaystyle (-1,+1)}$ and independent of the ratio ${\displaystyle Y/X,}$ thus, ${\displaystyle P(Z\leq 0.5|Y/X)=0.75.}$ On the other hand, the inequality ${\displaystyle z\leq 0.5}$ holds on an arc of the circle ${\displaystyle x^{2}+y^{2}+z^{2}=1,}$ ${\displaystyle y=cx}$ (for any given ${\displaystyle c}$). The length of the arc is 2/3 of the length of the circle. However, the conditional probability is 3/4, not 2/3. This is a manifestation of the classical Borel paradox[1] [2].

"Appeals to symmetry can be misleading if not formalized as invariance arguments." Pollard[3]

Another example. A random rotation of the three-dimensional space is a rotation by a random angle around a random axis. Geometric intuition suggests that the angle is independent of the axis and distributed uniformly. However, the latter is wrong; small values of the angle are less probable.

### The limiting procedure

Given an event ${\displaystyle B}$ of zero probability, the formula ${\displaystyle \textstyle \mathbb {P} (A|B)=\mathbb {P} (A\cap B)/\mathbb {P} (B)}$ is useless, however, one can try ${\displaystyle \textstyle \mathbb {P} (A|B)=\lim _{n\to \infty }\mathbb {P} (A\cap B_{n})/\mathbb {P} (B_{n})}$ for an appropriate sequence of events ${\displaystyle B_{n}}$ of nonzero probability such that ${\displaystyle B_{n}\downarrow B}$ (that is, ${\displaystyle \textstyle B_{1}\supset B_{2}\supset \dots }$ and ${\displaystyle \textstyle B_{1}\cap B_{2}\cap \dots =B}$). One example is given above. Two more examples are Brownian bridge and Brownian excursion.

In the latter two examples the law of total probability is irrelevant, since only a single event (the condition) is given. In contrast, in the example above the law of total probability applies, since the event ${\displaystyle X=0.5}$ is included into a family of events ${\displaystyle X=x}$ where ${\displaystyle x}$ runs over ${\displaystyle (-1,1),}$ and these events are a partition of the probability space.

In order to avoid paradoxes (such as the Borel's paradox), the following important distinction should be taken into account. If a given event is of nonzero probability then conditioning on it is well-defined (irrespective of any other events), as was noted above. In contrast, if the given event is of zero probability then conditioning on it is ill-defined unless some additional input is provided. Wrong choice of this additional input leads to wrong conditional probabilities (expectations, distributions). In this sense, "the concept of a conditional probability with regard to an isolated hypothesis whose probability equals 0 is inadmissible." (Kolmogorov; quoted in [3]).

The additional input may be (a) a symmetry (invariance group); (b) a sequence of events ${\displaystyle B_{n}}$ such that ${\displaystyle B_{n}\downarrow B,}$ ${\displaystyle P(B_{n})>0;}$ (c) a partition containing the given event. Measure-theoretic conditioning (below) investigates Case (c), discloses its relation to (b) in general and to (a) when applicable.

Some events of zero probability are beyond the reach of conditioning. An example: let ${\displaystyle X_{n}}$ be independent random variables distributed uniformly on ${\displaystyle (0,1),}$ and ${\displaystyle B}$ the event "${\displaystyle X_{n}\to 0}$ as ${\displaystyle n\to \infty }$"; what about ${\displaystyle P(X_{n}<0.5|B)?}$ Does it tend to 1, or not? Another example: let ${\displaystyle X}$ be a random variable distributed uniformly on ${\displaystyle (0,1),}$ and ${\displaystyle B}$ the event "${\displaystyle X}$ is a rational number"; what about ${\displaystyle P(X=1/n|B)?}$ The only answer is that, once again, "the concept of a conditional probability with regard to an isolated hypothesis whose probability equals 0 is inadmissible." (Kolmogorov, quoted in [3]).

## Conditioning on the level of measure theory

Example. Let ${\displaystyle Y}$ be a random variable distributed uniformly on ${\displaystyle (0,1),}$ and ${\displaystyle X=f(Y)}$ where ${\displaystyle f}$ is a given function. Two cases are treated below: ${\displaystyle f=f_{1}}$ and ${\displaystyle f=f_{2},}$ where ${\displaystyle f_{1}}$ is the continuous piecewise-linear function

${\displaystyle f_{1}(y)={\begin{cases}3y&{\text{for }}0\leq y\leq 1/3,\\1.5(1-y)&{\text{for }}1/3\leq y\leq 2/3,\\0.5&{\text{for }}2/3\leq y\leq 1,\end{cases}}}$

and ${\displaystyle f_{2}}$ is the everywhere continuous but nowhere differentiable Weierstrass function.

### Geometric intuition: caution

In the case ${\displaystyle f=f_{1},}$ given ${\displaystyle X=0.75,}$ two values of ${\displaystyle Y}$ are possible, 0.25 and 0.5. It may seem evident that both values are of conditional probability 0.5 just because one point is congruent to another point. However, this is an illusion; see below.

### Conditional probability

The conditional probability ${\displaystyle P(Y\leq 1/3|X)}$ may be defined as the best predictor of the indicator

${\displaystyle I={\begin{cases}1&{\text{if }}Y\leq 1/3,\\0&{\text{otherwise}},\end{cases}}}$

given X. That is, it minimizes the mean square error ${\displaystyle E(I-g(X))^{2}}$ on the class of all random variables of the form ${\displaystyle g(X).}$

In the case ${\displaystyle f=f_{1}}$ the corresponding function ${\displaystyle g=g_{1}}$ may be calculated explicitly,[4]

${\displaystyle g_{1}(x)={\begin{cases}1&{\text{for }}0

Alternatively, the limiting procedure may be used,

${\displaystyle g_{1}(x)=\lim _{\varepsilon \to 0+}\mathbb {P} (Y\leq 1/3|x-\varepsilon \leq X\leq x+\varepsilon )\,,}$

giving the same result.

Thus, ${\displaystyle P(Y\leq 1/3|X)=g_{1}(X).}$ The expectation of this random variable is equal to the (unconditional) probability, ${\displaystyle E(P(Y\leq 1/3|X))=P(Y\leq 1/3),}$ namely,

${\displaystyle 1\cdot \mathbb {P} (X<0.5)+0\cdot \mathbb {P} (X=0.5)+{\frac {1}{3}}\cdot \mathbb {P} (X>0.5)=1\cdot {\frac {1}{6}}+0\cdot {\frac {1}{3}}+{\frac {1}{3}}\cdot {\Big (}{\frac {1}{6}}+{\frac {1}{3}}{\Big )}={\frac {1}{3}}\,,}$

which is an instance of the law of total probability ${\displaystyle E(P(A|X))=P(A).}$

In the case ${\displaystyle f=f_{2}}$ the corresponding function ${\displaystyle g=g_{2}}$ probably cannot be calculated explicitly. Nevertheless it exists, and can be computed numerically. Indeed, the space ${\displaystyle L_{2}(\Omega )}$ of all square integrable random variables is a Hilbert space; the indicator ${\displaystyle I}$ is a vector of this space; and random variables of the form ${\displaystyle g(X)}$ are a (closed, linear) subspace. The orthogonal projection of this vector to this subspace is well-defined. It can be computed numerically, using finite-dimensional approximations to the infinite-dimensional Hilbert space.

Once again, the expectation of the random variable ${\displaystyle P(Y\leq 1/3|X)=g_{2}(X)}$ is equal to the (unconditional) probability, ${\displaystyle E(P(Y\leq 1/3|X))=P(Y\leq 1/3),}$ namely,

${\displaystyle \int _{0}^{1}g_{2}(f_{2}(y))\,\mathrm {d} y={\frac {1}{3}}\,.}$

However, the Hilbert space approach treats ${\displaystyle g_{2}}$ as an equivalence class of functions rather than an individual function. Measurability of ${\displaystyle g_{2}}$ is ensured, but continuity (or even Riemann integrability) is not. The value ${\displaystyle g_{2}(0.5)}$ is determined uniquely, since the point 0.5 is an atom of the distribution of ${\displaystyle X}$. Other values ${\displaystyle x}$ are not atoms, thus, corresponding values ${\displaystyle g_{2}(x)}$ are not determined uniquely. Once again, "the concept of a conditional probability with regard to an isolated hypothesis whose probability equals 0 is inadmissible." (Kolmogorov, quoted in [3]).

Alternatively, the same function ${\displaystyle g}$ (be it ${\displaystyle g_{1}}$ or ${\displaystyle g_{2}}$) may be defined as the Radon-Nikodym derivative

${\displaystyle g={\frac {\mathrm {d} \nu }{\mathrm {d} \mu }}\,,}$

where measures μ, ν are defined by

{\displaystyle {\begin{aligned}\mu (B)&=\mathbb {P} (X\in B)\,,\\\nu (B)&=\mathbb {P} (X\in B,\,Y\leq 1/3)\end{aligned}}}

for all Borel sets ${\displaystyle B\subset \mathbb {R} .}$ That is, μ is the (unconditional) distribution of ${\displaystyle X}$, while ν is one third of its conditional distribution,

${\displaystyle \nu (B)=\mathbb {P} (X\in B|Y\leq 1/3)\mathbb {P} (Y\leq 1/3)={\frac {1}{3}}\mathbb {P} (X\in B|Y\leq 1/3)\,.}$

Both approaches (via the Hilbert space, and via the Radon-Nikodym derivative) treat ${\displaystyle g}$ as an equivalence class of functions; two functions ${\displaystyle g}$ and ${\displaystyle g'}$ are treated as equivalent, if ${\displaystyle g(X)=g'(X)}$ almost surely. Accordingly, the conditional probability ${\displaystyle P(Y\leq 1/3|X)}$ is treated as an equivalence class of random variables; as usual, two random variables are treated as equivalent if they are equal almost surely.

### Conditional expectation

The conditional expectation ${\displaystyle E(Y|X)}$ may be defined as the best predictor of ${\displaystyle Y}$ given ${\displaystyle X}$. That is, it minimizes the mean square error ${\displaystyle E(Y-h(X))^{2}}$ on the class of all random variables of the form ${\displaystyle h(X).}$

In the case ${\displaystyle f=f_{1}}$ the corresponding function ${\displaystyle h=h_{1}}$ may be calculated explicitly,[5]

${\displaystyle h_{1}(x)={\begin{cases}x/3&{\text{for }}0

Alternatively, the limiting procedure may be used,

${\displaystyle h_{1}(x)=\lim _{\varepsilon \to 0+}\mathbb {E} (Y|x-\varepsilon \leq X\leq x+\varepsilon )\,,}$

giving the same result.

Thus, ${\displaystyle E(Y|X)=h_{1}(X).}$ The expectation of this random variable is equal to the (unconditional) expectation, ${\displaystyle E(E(Y|X))=E(Y),}$ namely,

{\displaystyle {\begin{aligned}&\int _{0}^{1}h_{1}(f_{1}(y))\,\mathrm {d} y=\int _{0}^{1/6}{\frac {3y}{3}}\,\mathrm {d} y+\\&\quad +\int _{1/6}^{1/3}{\frac {2-3y}{3}}\,\mathrm {d} y+\int _{1/3}^{2/3}{\frac {2-1.5(1-y)}{3}}\,\mathrm {d} y+\int _{2/3}^{1}{\frac {5}{6}}\,\mathrm {d} y={\frac {1}{2}}\,,\end{aligned}}}

which is an instance of the law of total expectation ${\displaystyle E(E(Y|X))=E(Y).}$

In the case ${\displaystyle f=f_{2}}$ the corresponding function ${\displaystyle h=h_{2}}$ probably cannot be calculated explicitly. Nevertheless it exists, and can be computed numerically in the same way as ${\displaystyle g_{2}}$ above, — as the orthogonal projection in the Hilbert space. The law of total expectation holds, since the projection cannot change the scalar product by the constant function 1 belonging to the subspace.

Alternatively, the same function ${\displaystyle h}$ (be it ${\displaystyle h_{1}}$ or ${\displaystyle h_{2}}$) may be defined as the Radon-Nikodym derivative

${\displaystyle h={\frac {\mathrm {d} \nu }{\mathrm {d} \mu }}\,,}$

where measures ${\displaystyle \mu ,\nu }$ are defined by

{\displaystyle {\begin{aligned}\mu (B)&=\mathbb {P} (X\in B)\,,\\\nu (B)&=\mathbb {E} (Y,\,X\in B)\end{aligned}}}

for all Borel sets ${\displaystyle B\subset \mathbb {R} .}$ Here ${\displaystyle E(Y;A)}$ is the restricted expectation, not to be confused with the conditional expectation ${\displaystyle E(Y|A)=E(Y;A)/P(A).}$

### Conditional distribution

In the case ${\displaystyle f=f_{1}}$ the conditional cumulative distribution function may be calculated explicitly, similarly to ${\displaystyle g_{1}.}$ The limiting procedure gives

{\displaystyle {\begin{aligned}&F_{Y|X=0.75}(y)=\mathbb {P} (Y\leq y|X=0.75)=\\&=\lim _{\varepsilon \to 0+}\mathbb {P} (Y\leq y|0.75-\varepsilon \leq X\leq 0.75+\varepsilon )=\\&={\begin{cases}0&{\text{for }}-\infty

which cannot be correct, since a cumulative distribution function must be right-continuous!

This paradoxical result is explained by measure theory as follows. For a given ${\displaystyle y}$ the corresponding ${\displaystyle F_{Y|X=x}(y)=P(Y\leq y|X=x)}$ is well-defined (via the Hilbert space or the Radon-Nikodym derivative) as an equivalence class of functions (of ${\displaystyle x}$). Treated as a function of ${\displaystyle y}$ for a given ${\displaystyle x}$ it is ill-defined unless some additional input is provided. Namely, a function (of ${\displaystyle x}$) must be chosen within every (or at least almost every) equivalence class. Wrong choice leads to wrong conditional cumulative distribution functions.

A right choice can be made as follows. First, ${\displaystyle F_{Y|X=x}(y)=P(Y\leq y|X=x)}$ is considered for rational numbers ${\displaystyle y}$ only. (Any other dense countable set may be used equally well.) Thus, only a countable set of equivalence classes is used; all choices of functions within these classes are mutually equivalent, and the corresponding function of rational ${\displaystyle y}$ is well-defined (for almost every ${\displaystyle x}$). Second, the function is extended from rational numbers to real numbers by right continuity.

In general the conditional distribution is defined for almost all ${\displaystyle x}$ (according to the distribution of ${\displaystyle X}$), but sometimes the result is continuous in ${\displaystyle x}$, in which case individual values are acceptable. In the considered example this is the case; the correct result for ${\displaystyle x=0.75,}$

{\displaystyle {\begin{aligned}&F_{Y|X=0.75}(y)=\mathbb {P} (Y\leq y|X=0.75)=\\&={\begin{cases}0&{\text{for }}-\infty

shows that the conditional distribution of ${\displaystyle Y}$ given ${\displaystyle X=0.75}$ consists of two atoms, at 0.25 and 0.5, of probabilities 1/3 and 2/3 respectively.

Similarly, the conditional distribution may be calculated for all ${\displaystyle x}$ in ${\displaystyle (0,0.5)}$ or ${\displaystyle (0.5,1).}$

The value ${\displaystyle x=0.5}$ is an atom of the distribution of ${\displaystyle X}$, thus, the corresponding conditional distribution is well-defined and may be calculated by elementary means (the denominator does not vanish); the conditional distribution of ${\displaystyle Y}$ given ${\displaystyle X=0.5}$ is uniform on ${\displaystyle (2/3,1).}$ Measure theory leads to the same result.

The mixture of all conditional distributions is the (unconditional) distribution of ${\displaystyle Y}$.

The conditional expectation ${\displaystyle E(Y|X=x)}$ is nothing but the expectation with respect to the conditional distribution.

In the case ${\displaystyle f=f_{2}}$ the corresponding ${\displaystyle F_{Y|X=x}(y)=P(Y\leq y|X=x)}$ probably cannot be calculated explicitly. For a given ${\displaystyle y}$ it is well-defined (via the Hilbert space or the Radon-Nikodym derivative) as an equivalence class of functions (of ${\displaystyle x}$). The right choice of functions within these equivalence classes may be made as above; it leads to correct conditional cumulative distribution functions, thus, conditional distributions. In general, conditional distributions need not be atomic or absolutely continuous (nor mixtures of both types). Probably, in the considered example they are singular (like the Cantor distribution).

Once again, the mixture of all conditional distributions is the (unconditional) distribution, and the conditional expectation is the expectation with respect to the conditional distribution.

## Notes

1. Pollard 2002, Sect. 5.5, Example 17 on page 122
2. Durrett 1996, Sect. 4.1(a), Example 1.6 on page 224
3. Pollard 2002, Sect. 5.5, page 122
4. Proof:
{\displaystyle {\begin{aligned}&\mathbb {E} (I-g(X))^{2}=\\&=\int _{0}^{1/3}(1-g(3y))^{2}\,\mathrm {d} y+\int _{1/3}^{2/3}g^{2}(1.5(1-y))\,\mathrm {d} y+\int _{2/3}^{1}g^{2}(0.5)\,\mathrm {d} y=\\&=\int _{0}^{1}(1-g(x))^{2}{\frac {\mathrm {d} x}{3}}+\int _{0.5}^{1}g^{2}(x){\frac {\mathrm {d} x}{1.5}}+{\frac {1}{3}}g^{2}(0.5)=\\&={\frac {1}{3}}\int _{0}^{0.5}(1-g(x))^{2}\,\mathrm {d} x+{\frac {1}{3}}g^{2}(0.5)+{\frac {1}{3}}\int _{0.5}^{1}((1-g(x))^{2}+2g^{2}(x))\,\mathrm {d} x\,;\end{aligned}}}
it remains to note that ${\displaystyle (1-a)^{2}+2a^{2}}$ is minimal at ${\displaystyle a=1/3.}$
5. Proof: {\displaystyle {\begin{aligned}&\mathbb {E} (Y-h_{1}(X))^{2}=\int _{0}^{1}{\Big (}y-h_{1}(f_{1}(x)){\Big )}^{2}\,\mathrm {d} y=\\&\int _{0}^{1/3}(y-h_{1}(3y))^{2}\,\mathrm {d} y+\int _{1/3}^{2/3}{\Big (}y-h_{1}(1.5(1-y)){\Big )}^{2}\,\mathrm {d} y+\int _{2/3}^{1}{\Big (}y-h_{1}(0.5){\Big )}^{2}\,\mathrm {d} y=\\&\int _{0}^{1}{\Big (}{\frac {x}{3}}-h_{1}(x){\Big )}^{2}{\frac {\mathrm {d} x}{3}}+\int _{0.5}^{1}{\Big (}1-{\frac {x}{1.5}}-h_{1}(x){\Big )}^{2}{\frac {\mathrm {d} x}{1.5}}+{\frac {1}{3}}h_{1}^{2}(0.5)-{\frac {5}{9}}h_{1}(0.5)+{\frac {19}{81}}=\\&{\frac {1}{3}}\int _{0}^{0.5}{\Big (}h_{1}(x)-{\frac {x}{3}}{\Big )}^{2}\,\mathrm {d} x+{\frac {1}{3}}h_{1}^{2}(0.5)-{\frac {5}{9}}h_{1}(0.5)+{\frac {19}{81}}+\\&\quad {\frac {1}{3}}\int _{0.5}^{1}{\bigg (}{\Big (}h_{1}(x)-{\frac {x}{3}}{\Big )}^{2}+2{\Big (}h_{1}(x)-1+{\frac {2x}{3}}{\Big )}^{2}{\bigg )}\,\mathrm {d} x\,;\end{aligned}}} it remains to note that ${\displaystyle \textstyle (a-{\frac {x}{3}})^{2}+2(a-1+{\frac {2x}{3}})^{2}}$ is minimal at ${\displaystyle \textstyle a={\frac {2-x}{3}},}$ and ${\displaystyle \textstyle {\frac {1}{3}}a^{2}-{\frac {5}{9}}a}$ is minimal at ${\displaystyle \textstyle a={\frac {5}{6}}.}$

## References

• Durrett, Richard (1996), Probability: theory and examples (Second ed.)
• Pollard, David (2002), A user's guide to measure theoretic probability, Cambridge University Press