Tutorials › Statistical Theory I - Probability and Distribution Theory › Scalar Gaussian Conditioning With Numerical Examples

Gaussian Conditioning and Linear Maps · Tutorial 727 of 994

Scalar Gaussian Conditioning With Numerical Examples

Use covariance or correlation to calculate and interpret the conditional normal law, then check the result through its density and regression-residual representation.

Advanced 10 min read

What You'll Learn

  • State the conditions under which the scalar conditional normal density applies
  • Calculate the conditional mean using covariance or correlation
  • Calculate and interpret the conditional variance and standard deviation
  • Derive the conditional density by completing the square
  • Work numerical examples with positive, negative, and moderate correlation
  • Recognize when perfect correlation makes the conditional law degenerate

Why Scalar Gaussian Conditioning Is Useful

When two measurements are jointly normal, learning the value of one changes what is reasonable to expect for the other. The direction and size of that change depend on their covariance, while the remaining uncertainty depends on how strongly the variables are associated. Scalar conditioning makes these two effects explicit and gives a direct way to calculate the resulting density.

The calculations below concern a pair of jointly normal scalar random variables. The pair must be jointly normal: knowing only that each variable separately has a normal distribution is not enough to justify the conditional normal formula.

Definition: Let \(X\) and \(Y\) be jointly normal, with \(E[X]=\mu_X\), \(E[Y]=\mu_Y\), \(\operatorname{Var}(X)=\sigma_X^2>0\), \(\operatorname{Var}(Y)=\sigma_Y^2>0\), and \(\operatorname{Cov}(X,Y)=c\). Their correlation is \(\rho=c/(\sigma_X\sigma_Y)\). If \(|\rho|<1\), the pair is nondegenerate and has a joint density. For a fixed observed value \(y\), the conditional law of \(X\) given \(Y=y\) has mean \(\mu_X+(c/\sigma_Y^2)(y-\mu_Y)\) and variance \(\sigma_X^2-c^2/\sigma_Y^2\).

Equivalently, because \(c=\rho\sigma_X\sigma_Y\), the conditional mean is \(\mu_X+\rho(\sigma_X/\sigma_Y)(y-\mu_Y)\), and the conditional variance is \(\sigma_X^2(1-\rho^2)\). The variance is positive when \(|\rho|<1\). The statement “given \(Y=y\)” uses a conditional distribution defined as a function of \(y\); even when \(P(Y=y)=0\), its density formula is well-defined.

Deriving the Conditional Density

For \(|\rho|<1\), the joint density of \(X\) and \(Y\), written using their standardized values \(u=(x-\mu_X)/\sigma_X\) and \(v=(y-\mu_Y)/\sigma_Y\), is

$$ f_{X,Y}(x,y)= \frac{1}{2\pi\sigma_X\sigma_Y\sqrt{1-\rho^2}} \exp\!\left\{-\frac{u^2-2\rho uv+v^2}{2(1-\rho^2)}\right\}. $$

The key algebraic step is completing the square in the terms involving \(u\):

$$ u^2-2\rho uv+v^2=(u-\rho v)^2+(1-\rho^2)v^2. $$

The marginal density of \(Y\) is \(f_Y(y)=(\sigma_Y\sqrt{2\pi})^{-1}\exp(-v^2/2)\). Dividing the joint density by this positive marginal density gives the conditional density. The \(v^2\) terms cancel, leaving a normal density in \(x\).

Theorem: Under the conditions in the definition, for every real \(y\), a version of the conditional density of \(X\) given \(Y=y\) is
$$ f_{X\mid Y}(x\mid y)= \frac{1}{\sqrt{2\pi\sigma_X^2(1-\rho^2)}} \exp\!\left[ -\frac{\left(x-\mu_X-\rho\frac{\sigma_X}{\sigma_Y}(y-\mu_Y)\right)^2} {2\sigma_X^2(1-\rho^2)} \right]. $$

Proof. Substitute the completed-square identity into the joint density. The factor involving \(v\) becomes \(\exp(-v^2/2)\), which is exactly the exponential part of \(f_Y(y)\). After dividing by \(f_Y(y)\), the remaining exponential is \(\exp\{-(u-\rho v)^2/[2(1-\rho^2)]\}\). Since \(u-\rho v\) equals \[ \frac{x-\mu_X-\rho(\sigma_X/\sigma_Y)(y-\mu_Y)}{\sigma_X}, \] the exponent has the stated conditional mean and variance. The remaining constant is \(1/(\sigma_X\sqrt{2\pi(1-\rho^2)})\), which is the normalizing constant for that variance. Thus the displayed expression integrates to one as a density in \(x\). \(\square\)

Regression Residuals and Conditional Moments

The same formula has a useful representation: after accounting for the linear change associated with \(Y\), the leftover part of \(X\) is normal and independent of \(Y\). This gives another way to understand why conditioning shifts the mean but leaves a constant conditional variance.

Theorem: Suppose the conditions above hold, and set \(\beta=c/\sigma_Y^2\) and \(R=X-\mu_X-\beta(Y-\mu_Y)\). Then \(R\sim N(0,\tau^2)\), where \(\tau^2=\sigma_X^2-c^2/\sigma_Y^2\), and \(R\) is independent of \(Y\). Consequently, \(X\mid Y=y\) has mean \(\mu_X+\beta(y-\mu_Y)\) and variance \(\tau^2\).

Proof. The pair \((R,Y)\) is jointly normal because it is an affine transformation of the jointly normal pair \((X,Y)\). Direct calculation gives

$$ E[R]=0,\qquad \operatorname{Var}(R)=\sigma_X^2-2\beta c+\beta^2\sigma_Y^2 =\sigma_X^2-\frac{c^2}{\sigma_Y^2}=\tau^2, $$

and

$$ \operatorname{Cov}(R,Y)=c-\beta\sigma_Y^2=0. $$

To verify independence directly, transform from \((X,Y)\) to \((R,Y)\). The inverse transformation is \(x=r+\mu_X+\beta(y-\mu_Y)\), and its Jacobian determinant is \(1\). By the conditional density already derived, \(X\mid Y=y\) has mean \(\mu_X+\beta(y-\mu_Y)\) and variance \(\tau^2\). Therefore, at the corresponding \(x\), the conditional density is the \(N(0,\tau^2)\) density evaluated at \(r\). Multiplying this conditional density by \(f_Y(y)\) gives \(f_{R,Y}(r,y)=f_R(r)f_Y(y)\). This factorization proves independence. Since \(X=\mu_X+\beta(Y-\mu_Y)+R\), conditioning on \(Y=y\) leaves only the independent \(R\) as random variation; its mean is zero and its variance is \(\tau^2\). \(\square\)

Worked Numerical Calculations

Worked Example: Positive Correlation Raises the Conditional Mean

Suppose \(X\) and \(Y\) are jointly normal with \(X\sim N(10,4)\), \(Y\sim N(20,9)\), and correlation \(\rho=0.6\). Find the conditional distribution of \(X\) when \(Y=23\), and evaluate its density at \(x=12.8\).

The standard deviations are \(\sigma_X=2\) and \(\sigma_Y=3\), so the covariance is \(c=\rho\sigma_X\sigma_Y=0.6(2)(3)=3.6\). The observed value \(23\) is \(3\) units above the mean of \(Y\). Thus

$$ E[X\mid Y=23]=10+\frac{3.6}{9}(23-20)=10+1.2=11.2. $$

The conditional variance and standard deviation are

$$ \operatorname{Var}(X\mid Y=23)=4-\frac{3.6^2}{9} =4-\frac{12.96}{9}=2.56,\qquad \operatorname{SD}(X\mid Y=23)=1.6. $$

Therefore \(X\mid Y=23\sim N(11.2,2.56)\). The value \(x=12.8\) is one conditional standard deviation above the conditional mean, since \((12.8-11.2)/1.6=1\). Its conditional density is

$$ f_{X\mid Y}(12.8\mid23) =\frac{1}{1.6\sqrt{2\pi}}e^{-1/2} \approx 0.1512. $$

The positive correlation makes a value of \(Y\) above its mean pull the conditional mean of \(X\) above its mean as well.

Worked Example: Negative Correlation Reverses the Shift

Let \(X\) and \(Y\) be jointly normal with \(X\sim N(50,100)\), \(Y\sim N(30,16)\), and \(\rho=-0.75\). Find the conditional law of \(X\) given \(Y=34\).

Here \(\sigma_X=10\), \(\sigma_Y=4\), and \(c=(-0.75)(10)(4)=-30\). Since \(34-30=4\),

$$ E[X\mid Y=34]=50+\frac{-30}{16}(4) =50-7.5=42.5. $$

The conditional variance is

$$ \operatorname{Var}(X\mid Y=34)=100-\frac{(-30)^2}{16} =100-\frac{900}{16}=43.75. $$

Thus \(X\mid Y=34\sim N(42.5,43.75)\), with standard deviation \(\sqrt{43.75}\approx6.614\). The density at any specified \(x\) is

$$ f_{X\mid Y}(x\mid34)= \frac{1}{\sqrt{2\pi(43.75)}} \exp\!\left[-\frac{(x-42.5)^2}{2(43.75)}\right]. $$

Because \(Y=34\) is above its mean but the correlation is negative, the conditional mean of \(X\) moves below \(50\), not above it.

Worked Example: A Density With a Different Scale

Suppose \(X\) and \(Y\) are jointly normal with \(X\sim N(4,9)\), \(Y\sim N(2,4)\), and covariance \(c=3\). Find the conditional law of \(X\) given \(Y=0\), then evaluate the conditional density at \(x=5\).

The standard deviations are \(3\) and \(2\), so \(\rho=3/(3\cdot2)=0.5\). The conditional mean is

$$ 4+\frac{3}{4}(0-2)=4-1.5=2.5. $$

The conditional variance is \(9-3^2/4=9-2.25=6.75=27/4\). Hence \(X\mid Y=0\sim N(2.5,27/4)\). At \(x=5\), the difference from the conditional mean is \(2.5\), giving

$$ f_{X\mid Y}(5\mid0) =\frac{1}{\sqrt{2\pi(27/4)}} \exp\!\left[-\frac{(5-2.5)^2}{2(27/4)}\right] =\frac{1}{\sqrt{27\pi/2}}e^{-25/54} \approx 0.0967. $$

This example checks that the second argument of the normal distribution is the variance: the conditional variance is \(27/4\), not its square root.

Interpreting the Formula and Avoiding Common Errors

The conditional mean is a linear function of the observed value \(y\). Its slope is \(c/\sigma_Y^2\), or \(\rho\sigma_X/\sigma_Y\). Positive correlation gives a positive slope; negative correlation gives a negative slope. The conditional variance does not depend on the particular value observed: it is \(\sigma_X^2(1-\rho^2)\). As \(|\rho|\) approaches one, this variance approaches zero, reflecting that \(Y\) nearly determines \(X\).

A common mistake is to subtract \(\rho^2\) directly from \(\sigma_X^2\). The correct formula is \(\sigma_X^2(1-\rho^2)\), or equivalently \(\sigma_X^2-c^2/\sigma_Y^2\). The correlation is dimensionless, while a variance has squared measurement units; the incorrect subtraction may even combine quantities with incompatible units. Another mistake is to use \(c/\sigma_X^2\) for the slope when predicting \(X\) from \(Y\). The denominator must be the variance of the variable being conditioned on, \(\sigma_Y^2\).

If \(\rho=0\), the conditional mean and variance reduce to \(\mu_X\) and \(\sigma_X^2\), respectively. For a jointly normal pair, the conditional law is then unchanged by observing \(Y\). If \(|\rho|=1\), the pair is degenerate: \(X\) is an exact affine function of \(Y\), so the conditional distribution is a point mass rather than a density with positive variance. The density formula above therefore requires \(|\rho|<1\).

Key takeaway: For a nondegenerate jointly normal pair, update the mean by \((\operatorname{Cov}(X,Y)/\operatorname{Var}(Y))(y-\mu_Y)\), and reduce the variance by \(\operatorname{Cov}(X,Y)^2/\operatorname{Var}(Y)\). Keep the conditioning variable in the denominator and distinguish variance from standard deviation.

Check Your Understanding

Work each question using the conditional formulas, and check that every conditional variance is positive when the pair is nondegenerate.

  1. If \(\operatorname{Var}(X)=25\), \(\operatorname{Var}(Y)=4\), \(c=5\), and the means are \(0\) and \(0\), what are the conditional mean and variance of \(X\) given \(Y=2\)?
  2. When \(X\) and \(Y\) have negative correlation, what happens to the conditional mean of \(X\) when the observed \(y\) is above \(\mu_Y\)?
  3. Why is \(c/\sigma_Y^2\), rather than \(c/\sigma_X^2\), the slope in the conditional mean of \(X\) given \(Y=y\)?
  4. For a jointly normal pair with \(\rho=0\), what are the conditional mean and variance of \(X\) given \(Y=y\)?
  5. What changes in the conditional law when \(|\rho|=1\), and why is the positive-variance density formula then inapplicable?