## ⓘ Conditional probability distribution

In probability theory and statistics, given two jointly distributed random variables X {\displaystyle X} and Y {\displaystyle Y}, the conditional probability distribution of Y given X is the probability distribution of Y {\displaystyle Y} when X {\displaystyle X} is known to be a particular value; in some cases the conditional probabilities may be expressed as functions containing the unspecified value x {\displaystyle x} of X {\displaystyle X} as a parameter. When both X {\displaystyle X} and Y {\displaystyle Y} are categorical variables, a conditional probability table is typically used to represent the conditional probability. The conditional distribution contrasts with the marginal distribution of a random variable, which is its distribution without reference to the value of the other variable.

If the conditional distribution of Y {\displaystyle Y} given X {\displaystyle X} is a continuous distribution, then its probability density function is known as the conditional density function. The properties of a conditional distribution, such as the moments, are often referred to by corresponding names such as the conditional mean and conditional variance.

More generally, one can refer to the conditional distribution of a subset of a set of more than two variables; this conditional distribution is contingent on the values of all the remaining variables, and if more than one variable is included in the subset then this conditional distribution is the conditional joint distribution of the included variables.

## 1. Conditional discrete distributions

For discrete random variables, the conditional probability mass function of Y {\displaystyle Y} given X = x {\displaystyle X=x} can be written according to its definition as:

Due to the occurrence of P X = x {\displaystyle PX=x} in a denominator, this is defined only for non-zero hence strictly positive P X = x. {\displaystyle PX=x.}

The relation with the probability distribution of X {\displaystyle X} given Y {\displaystyle Y} is:

P Y = y ∣ X = x P X = x = P { X = x } ∩ { Y = y } = P X = x ∣ Y = y P Y = y. {\displaystyle PY=y\mid X=xPX=x=P\{X=x\}\cap \{Y=y\}=PX=x\mid Y=yPY=y.}### * 1.1. Conditional discrete distributions * Example

Consider the roll of a fair die and let X = 1 {\displaystyle X=1} if the number is even i.e. 2, 4, or 6 and X = 0 {\displaystyle X=0} otherwise. Furthermore, let Y = 1 {\displaystyle Y=1} if the number is prime i.e. 2, 3, or 5 and Y = 0 {\displaystyle Y=0} otherwise.

Then the unconditional probability that X = 1 {\displaystyle X=1} is 3/6 = 1/2 since there are six possible rolls of the die, of which three are even, whereas the probability that X = 1 {\displaystyle X=1} conditional on Y = 1 {\displaystyle Y=1} is 1/3 since there are three possible prime number rolls - 2, 3, and 5 - of which one is even.

## 2. Conditional continuous distributions

Similarly for continuous random variables, the conditional probability density function of Y {\displaystyle Y} given the occurrence of the value x {\displaystyle x} of X {\displaystyle X} can be written as

where f X, Y x, y {\displaystyle f_{X,Y}x,y} gives the joint density of X {\displaystyle X} and Y {\displaystyle Y}, while f x {\displaystyle f_{X}x} gives the marginal density for X {\displaystyle X}. Also in this case it is necessary that f x > 0 {\displaystyle f_{X}x> 0}.

The relation with the probability distribution of X {\displaystyle X} given Y {\displaystyle Y} is given by:

f Y ∣ X y ∣ x f x = f X, Y x, y = f X | Y x ∣ y f Y y. {\displaystyle f_{Y\mid X}y\mid xf_{X}x=f_{X,Y}x,y=f_{X|Y}x\mid yf_{Y}y.}The concept of the conditional distribution of a continuous random variable is not as intuitive as it might seem: Borels paradox shows that conditional probability density functions need not be invariant under coordinate transformations.

### * 2.1. Conditional continuous distributions * Example

The graph shows a bivariate normal joint density for random variables X {\displaystyle X} and Y {\displaystyle Y}. To see the distribution of Y {\displaystyle Y} conditional on X = 70 {\displaystyle X=70}, one can first visualize the line X = 70 {\displaystyle X=70} in the X, Y {\displaystyle X,Y} plane, and then visualize the plane containing that line and perpendicular to the X, Y {\displaystyle X,Y} plane. The intersection of that plane with the joint normal density, once rescaled to give unit area under the intersection, is the relevant conditional density of Y {\displaystyle Y}.

Y ∣ X = 70 ∼ N μ 1 + σ 1 σ 2 ρ 70 − μ 2, 1 − ρ 2 σ 1 2). {\displaystyle Y\mid X=70\ \sim \ {\mathcal {N}}\left\mu _{1}+{\frac {\sigma _{1}}{\sigma _{2}}}\rho 70-\mu _{2},\,1-\rho ^{2}\sigma _{1}^{2}\right).}

## 3. Relation to independence

Random variables X {\displaystyle X}, Y {\displaystyle Y} are independent if and only if the conditional distribution of Y {\displaystyle Y} given X {\displaystyle X} is, for all possible realizations of X {\displaystyle X}, equal to the unconditional distribution of Y {\displaystyle Y}. For discrete random variables this means P Y = y | X = x = P Y = y {\displaystyle PY=y|X=x=PY=y} for all possible y {\displaystyle y} and x {\displaystyle x} with P X = x > 0 {\displaystyle PX=x> 0}. For continuous random variables X {\displaystyle X} and Y {\displaystyle Y}, having a joint density function, it means f y | X = x = f y {\displaystyle f_{Y}y|X=x=f_{Y}y} for all possible y {\displaystyle y} and x {\displaystyle x} with f x > 0 {\displaystyle f_{X}x> 0}.

## 4. Properties

Seen as a function of y {\displaystyle y} for given x {\displaystyle x}, P Y = y | X = x {\displaystyle PY=y|X=x} is a probability mass function and so the sum over all y {\displaystyle y} or integral if it is a conditional probability density is 1. Seen as a function of x {\displaystyle x} for given y {\displaystyle y}, it is a likelihood function, so that the sum over all x {\displaystyle x} need not be 1.

Additionally, a marginal of a joint distribution can be expressed as the expectation of the corresponding conditional distribution. For instance, p x = E Y }.

## 5. Measure-theoretic formulation

Let Ω, F, P {\displaystyle \Omega,{\mathcal {F}},P} be a probability space, G ⊆ F {\displaystyle {\mathcal {G}}\subseteq {\mathcal {F}}} a σ {\displaystyle \sigma } -field in F {\displaystyle {\mathcal {F}}}, and X: Ω → R {\displaystyle X:\Omega \to \mathbb {R} } a real-valued random variable measurable with respect to the Borel σ {\displaystyle \sigma } -field R 1 {\displaystyle {\mathcal {R}}^{1}} on R {\displaystyle \mathbb {R} }. Given A ∈ F {\displaystyle A\in {\mathcal {F}}}, the Radon-Nikodym theorem implies that there is a G {\displaystyle {\mathcal {G}}} -measurable integrable random variable P A ∣ G: Ω → R {\displaystyle PA\mid {\mathcal {G}}:\Omega \to \mathbb {R} } so that ∫ G P A ∣ G ω d P ω = P A ∩ G {\displaystyle \int _{G}PA\mid {\mathcal {G}}\omegadP\omega=PA\cap G} for every G ∈ G {\displaystyle G\in {\mathcal {G}}}, and such a random variable is uniquely defined up to sets of probability zero. Further, it can then be shown that there exists a function μ: R 1 × Ω → R {\displaystyle \mu:{\mathcal {R}}^{1}\times \Omega \to \mathbb {R} } such that

μ ⋅, ω {\displaystyle \mu \cdot,\omega} is a probability measure on R 1 {\displaystyle {\mathcal {R}}^{1}} for each ω ∈ Ω {\displaystyle \omega \in \Omega } i.e., it is regular and μ H, ⋅ = P X − 1 H ∣ G) {\displaystyle \mu H,\cdot=PX^{-1}H\mid {\mathcal {G}})} almost surely for every H ∈ R 1 {\displaystyle H\in {\mathcal {R}}^{1}}.

For any ω ∈ Ω {\displaystyle \omega \in \Omega }, the function μ ⋅, ω: R 1 → R {\displaystyle \mu \cdot,\omega:{\mathcal {R}}^{1}\to \mathbb {R} } is called a conditional probability distribution of X {\displaystyle X} given G {\displaystyle {\mathcal {G}}}. In this case, E =\int _{-\infty }^{\infty }x\,\mu dx,\cdot} almost surely.

## 6. Relation to conditional expectation

For any event A ∈ A ⊇ B {\displaystyle A\in {\mathcal {A}}\supseteq {\mathcal {B}}}, define the indicator function:

1 A ω = { 1 if ω ∈ A, 0 if ω ∉ A, {\displaystyle \mathbf {1} _{A}\omega={\begin{cases}1\;&{\text{if }}\omega \in A,\\0\;&{\text{if }}\omega \notin A,\end{cases}}}which is a random variable. Note that the expectation of this random variable is equal to the probability of A itself:

E 1 A = P A. {\displaystyle \operatorname {E} \mathbf {1} _{A}=\operatorname {P} A.\;}Then the conditional probability given B {\displaystyle \scriptstyle {\mathcal {B}}} is a function P ⋅ ∣ B: A × Ω → } such that P A ∣ B {\displaystyle \scriptstyle \operatorname {P} A\mid {\mathcal {B}}} is the conditional expectation of the indicator function for A {\displaystyle A}:

P A ∣ B = E 1 A ∣ B {\displaystyle \operatorname {P} A\mid {\mathcal {B}}=\operatorname {E} \mathbf {1} _{A}\mid {\mathcal {B}}\;}In other words, P A ∣ B {\displaystyle \scriptstyle \operatorname {P} A\mid {\mathcal {B}}} is a B {\displaystyle \scriptstyle {\mathcal {B}}} -measurable function satisfying

∫ B P A ∣ B ω d P ω = P A ∩ B for all A ∈ A, B ∈ B. {\displaystyle \int _{B}\operatorname {P} A\mid {\mathcal {B}}\omega\,\mathrm {d} \operatorname {P} \omega=\operatorname {P} A\cap B\qquad {\text{for all}}\quad A\in {\mathcal {A}},B\in {\mathcal {B}}.}A conditional probability is regular if P ⋅ ∣ B ω {\displaystyle \scriptstyle \operatorname {P} \cdot \mid {\mathcal {B}}\omega} is also a probability measure for all ω ∈ Ω. An expectation of a random variable with respect to a regular conditional probability is equal to its conditional expectation.

- For the trivial sigma algebra B = { ∅, Ω } {\displaystyle {\mathcal {B}}=\{\emptyset,\Omega \}} the conditional probability is a constant function, P A ∣ { ∅, Ω } ≡ P A. {\displaystyle \operatorname {P} \!\leftA\mid \{\emptyset,\Omega \}\right\equiv \operatorname {P} A.}
- For A ∈ B {\displaystyle A\in {\mathcal {B}}}, as outlined above, P A ∣ B = 1 A. {\displaystyle \operatorname {P} A\mid {\mathcal {B}}=1_{A}.}