Joint Distributions and Transformations: Conditioning, Covariance, and Jacobians joint & marginal densities · conditional slicing · Eve’s law · optimal MSE predictor · covariance & correlation · Jacobian change of variables
Dependence, Predictability, and Correlation Differ
Motivation
Dependent (p_{X,Y} \ne p_X p_Y): On the unit disk, observing Y = 0.9 restricts |X| \le \sqrt{1 - 0.9^2} \approx 0.44.
Unpredictable in mean (\mathbb{E}[X \mid Y = y] = 0): Every horizontal chord is symmetric around 0, so knowing Y narrows the range of X without shifting its center.
Dart joint density: Constant p_{X,Y}(x, y) = 1/\pi inside the unit disk x^2 + y^2 \le 1 (area \pi) and 0 outside.
Why flat \ne factorized: Even though 1/\pi is constant inside the disk, the circular support indicator \mathbf{1}_{x^2 + y^2 \le 1} cannot factor as a(x)\,b(y).
Marginal Densities: Integrating Out Variables
The Sum Rule for Continuous Densities
To recover the density of X alone, sum the probabilities of small squares \epsilon^2 p_{X,Y}(x, \epsilon i) along the vertical strip at x and cancel \epsilon: p_X(x) = \int_{-\infty}^{\infty} p_{X,Y}(x, y)\,dy
Dart marginal is a semicircle: At horizontal position x \in [-1, 1], the vertical strip crosses the disk from y = -\sqrt{1-x^2} to +\sqrt{1-x^2}: p_X(x) = \int_{-\sqrt{1-x^2}}^{\sqrt{1-x^2}} \frac{1}{\pi}\,dy = \frac{2}{\pi}\sqrt{1 - x^2}
A flat joint density produces a curved marginal because chords through the center are longer than chords near the rim.
Conditional Densities: Slicing and Renormalizing
Conditioning on Zero-Probability Events
Because P(Y = y) = 0, the discrete formula P(X, Y)/P(Y) divides zero by zero. Conditioning on a thin strip Y \in [y, y+\epsilon] and sending \epsilon \downarrow 0 gives the conditional density: p_{X \mid Y}(x \mid y) = \frac{p_{X,Y}(x, y)}{p_Y(y)} \quad \text{for } p_Y(y) > 0
Geometric picture: Slice the joint surface p_{X,Y} along the horizontal line Y = y and divide by the slice area p_Y(y) so the profile integrates to 1.
Dart conditional: Given Y = y, X is uniform along the chord [-\sqrt{1-y^2}, \sqrt{1-y^2}] with density \frac{1}{2\sqrt{1-y^2}}.
Pulling out known factors: Within the strip Y = y, any function h(Y) behaves as a constant: \mathbb{E}\bigl[h(Y)\,g(X, Y) \mid Y\bigr] = h(Y)\,\mathbb{E}\bigl[g(X, Y) \mid Y\bigr]
Law of Total Expectation (Tower Property): Averaging the strip averages recovers the overall mean: \mathbb{E}\bigl[\mathbb{E}[X \mid Y]\bigr] = \int \left(\int x\,p_{X \mid Y}(x \mid y)\,dx\right) p_Y(y)\,dy = \iint x\,p_{X,Y}(x, y)\,dx\,dy = \mathbb{E}[X]
The Law of Total Variance (Eve’s Law)
Splitting Variance Into Within-Strip and Between-Strip Parts
Unexplained (within strips):\mathbb{E}[\mathrm{Var}(X \mid Y)] = \mathbb{E}[X^2] - \mathbb{E}[(\mathbb{E}[X \mid Y])^2] measures average spread left over inside each slice Y = y.
Explained (between strips):\mathrm{Var}(\mathbb{E}[X \mid Y]) = \mathbb{E}[(\mathbb{E}[X \mid Y])^2] - (\mathbb{E}[X])^2 measures how much the slice centers move across Y.
Orthogonal split: Writing X - h(Y) = (X - m(Y)) + (m(Y) - h(Y)) with m(Y) = \mathbb{E}[X \mid Y], the cross term vanishes in every strip Y = y.
Unique MSE minimizer & R^2 ceiling: Setting h(Y) = \mathbb{E}[X \mid Y] eliminates the second term, explaining at most fraction R^2 \le \frac{\mathrm{Var}(\mathbb{E}[X \mid Y])}{\mathrm{Var}(X)} of \mathrm{Var}(X).
Eve’s Law in Action: Dart vs. Gaussian Mixture
Analytic & Empirical Variance Decomposition
Dart on the disk (0\% explained): Each chord at height y is symmetric (\mathbb{E}[X \mid Y=y] = 0) with uniform variance (1 - y^2)/3. Since \mathbb{E}[Y^2] = \frac{1}{2}\mathbb{E}[R^2] = \frac{1}{4}: \mathrm{Var}(X) = \frac{1 - 1/4}{3} + \mathrm{Var}(0) = \frac{1}{4} + 0
Two-component mixture (72\% explained): Label Z \sim \mathrm{Bernoulli}(0.2) selects \mathcal{N}(3, 1) vs. \mathcal{N}(-1, 1). Within-group variance is 1; between-group variance is 0.2(0.8)(3 - (-1))^2 = 2.56 (total 3.56).
Simulating 10^6 mixture draws confirms that Eve’s law holds exactly for the empirical sample itself:
The covariance averages the product of deviations from the two means: \sigma_{XY} = \mathrm{Cov}(X, Y) = \mathbb{E}\bigl[(X - \mu_X)(Y - \mu_Y)\bigr] = \mathbb{E}[XY] - \mu_X\mu_Y
Dividing by both standard deviations strips away physical units to define the correlation coefficient: \rho(X, Y) = \frac{\mathrm{Cov}(X, Y)}{\sigma_X \sigma_Y} \in [-1, 1]
Proof of |\rho| \le 1 (Cauchy–Schwarz): For every t \in \mathbb{R}, \mathrm{Var}(tX + Y) = \sigma_X^2 t^2 + 2\,\mathrm{Cov}(X, Y)t + \sigma_Y^2 \ge 0 A non-negative quadratic has discriminant \Delta \le 0, giving \mathrm{Cov}(X,Y)^2 \le \sigma_X^2\sigma_Y^2, with \rho = \pm 1 \iff Y = cX + d.
Hilbert-space view: Under inner product \langle \tilde{X}, \tilde{Y} \rangle = \mathbb{E}[\tilde{X}\tilde{Y}], correlation is literally \cos\angle(\tilde{X}, \tilde{Y}).
Pitfall: Uncorrelated Does Not Mean Independent
Three Classic Counterexamples
Why \mathrm{Cov}(X, Y) = 0 is weaker than X \perp Y: Zero covariance only rules out a linear slope; symmetric nonlinear coupling leaves \mathbb{E}[XY] = \mathbb{E}[X]\mathbb{E}[Y] intact.
Three counterexamples: Circular disk (x^2+y^2 \le 1), parabola (Y = X^2), and random-sign Gaussian (Y = SX with |Y| = |X|).
Representation learning takeaway: Linear PCA whitening (\boldsymbol{\Sigma} = \mathbf{I}) removes linear correlation but does not make features independent unless they are jointly Gaussian.
The Covariance Matrix and Directional Variance
Second Moments of Random Vectors
For a random vector \mathbf{X} = (X_1, \dots, X_n)^\top with mean vector \boldsymbol{\mu} = \mathbb{E}[\mathbf{X}], the n \times ncovariance matrix collects all variances on its diagonal and pairwise covariances off-diagonal:
Symmetry:\boldsymbol{\Sigma}^\top = \boldsymbol{\Sigma} because \mathrm{Cov}(X_i, X_j) = \mathrm{Cov}(X_j, X_i).
Positive semidefiniteness (\boldsymbol{\Sigma} \succeq \mathbf{0}): Projecting \mathbf{X} onto any fixed direction vector \mathbf{a} \in \mathbb{R}^n produces a scalar random variable \mathbf{a}^\top \mathbf{X} whose variance is the quadratic form: \mathrm{Var}(\mathbf{a}^\top \mathbf{X}) = \mathbb{E}\bigl[\mathbf{a}^\top (\mathbf{X} - \boldsymbol{\mu})(\mathbf{X} - \boldsymbol{\mu})^\top \mathbf{a}\bigr] = \mathbf{a}^\top \boldsymbol{\Sigma}\mathbf{a} \ge 0
Spectral interpretation: The eigenvectors of \boldsymbol{\Sigma} point along the principal axes of variance (PCA), while for our symmetric dart on the unit disk, \boldsymbol{\Sigma} = \mathrm{diag}(1/4, 1/4).
1D Change of Variables: Conservation of Probability
How Transformations Reshape a Density
If X has density p_X and Y = g(X) for a smooth, strictly monotone map g, why is p_Y(y) \ne p_X(g^{-1}(y))?
Probability mass, not density height, is conserved: An interval of width \Delta x carries probability p_X(x)\Delta x and stretches to width \Delta y \approx |g'(x)|\Delta x: p_Y(y)\,\Delta y \approx p_X(x)\,\Delta x \implies p_Y(y) = \frac{p_X(x)}{|g'(x)|}
Formal 1D Rule: On the image interval g(I), p_Y(y) = p_X\bigl(g^{-1}(y)\bigr)\left|\frac{dg^{-1}}{dy}(y)\right|
Worked Example: Log-Normal vs. Naive Plug-In
Why the Jacobian Factor 1/y Shifts the Peak
Let X \sim \mathcal{N}(0, 1) and Y = e^X > 0. Here g^{-1}(y) = \log y and \left|\frac{dg^{-1}}{dy}\right| = \frac{1}{y}, yielding the log-normal density: p_Y(y) = \frac{1}{y\sqrt{2\pi}}\exp\!\left(-\frac{(\log y)^2}{2}\right), \quad y > 0
Peak shift: Differentiating \log p_Y(y) = -\log y - \frac{1}{2}(\log y)^2 + C gives mode y = e^{-1} \approx 0.368.
Failure of naive p_X(\log y): Omitting 1/y puts the peak at y = 1 and encloses total area \int p_X(x)e^x\,dx = \mathbb{E}[e^X] = e^{1/2} \approx 1.65 \ne 1.
Multivariate Change of Variables and Normalizing Flows
Local volume stretch: An invertible map \mathbf{y} = g(\mathbf{x}) expands volume by |\det J_g(\mathbf{x})|, so stacking L flow layers subtracts \sum_{\ell=1}^L \log|\det J_{g_\ell}|.
Triangular affine coupling (RealNVP): Setting y_1 = x_1 and y_2 = x_2 e^{s(x_1)} + t(x_1) makes J_g lower triangular with O(1) log-determinant s(x_1).
Coordinate Choice: The Dart in Polar Coordinates
Unknotting Dependence via a Jacobian
Express the dart’s Cartesian position (x, y) in polar coordinates (r, \theta) via (x, y) = (r\cos\theta, r\sin\theta):
Applying the multivariate change-of-variables rule from (x, y) (where p_{X,Y} = 1/\pi) to (r, \theta) \in [0, 1] \times [0, 2\pi): p_{R,\Theta}(r, \theta) = p_{X,Y}(r\cos\theta, r\sin\theta)\,\bigl|\det J_g(r, \theta)\bigr| = \frac{1}{\pi}\cdot r = \underbrace{2r}_{p_R(r)} \cdot \underbrace{\frac{1}{2\pi}}_{p_\Theta(\theta)}
Factorization into independent coordinates: In Cartesian coordinates, X and Y were coupled by the circular rim; in polar coordinates, the joint density factors cleanly into R \perp \Theta with p_R(r) = 2r and \Theta \sim \mathrm{Unif}[0, 2\pi).
Concept Check: Conditioning, Variance & Jacobians
Check Your Understanding
Test your grasp of joint distributions and density transformations on three problems:
Explained variance (R^2) ceiling: Using Eve’s law and the optimal predictor decomposition, what is the maximum R^2 = 1 - \frac{\mathbb{E}[(X - h(Y))^2]}{\mathrm{Var}(X)} any model h(Y) can achieve when predicting the dart’s X from Y?
Minimum correlation of n exchangeable variables: If Y_1, \dots, Y_n each have variance \sigma^2 and pairwise correlation \rho, use \mathrm{Var}(\sum_{i=1}^n Y_i) \ge 0 to find the smallest possible negative correlation \rho.
Unbounded transformed density: If U \sim \mathrm{Unif}(0, 1), what is the density p_Y(y) of Y = U^2 on (0, 1)? Why does it blow up near y = 0 while still integrating to 1?
Answers:
R^2 \le \frac{\mathrm{Var}(\mathbb{E}[X \mid Y])}{\mathrm{Var}(X)}. For the dart, \mathbb{E}[X \mid Y] = 0 is constant, so \mathrm{Var}(\mathbb{E}[X \mid Y]) = 0 and the ceiling is R^2 = 0 for every predictor h(Y).
g^{-1}(y) = \sqrt{y} has derivative \frac{1}{2\sqrt{y}}, so p_Y(y) = \frac{1}{2\sqrt{y}} on (0, 1). Squaring strongly compresses intervals near 0, piling probability density to \infty as y \downarrow 0, yet \int_0^1 \frac{1}{2\sqrt{y}}\,dy = [\sqrt{y}]_0^1 = 1.
Summary: Joint Distributions and Transformations
Key Takeaways
Operation / Theorem
Mathematical Formula
Dart / Worked Benchmark
Deep Learning Role
Marginalization
p_X(x) = \int_{-\infty}^\infty p_{X,Y}(x, y)\,dy
Flat disk 1/\pi \to semicircle \frac{2}{\pi}\sqrt{1-x^2}
Integrating out latent variables
Conditioning & Independence
p_{X\mid Y}(x\mid y) = \frac{p_{X,Y}(x,y)}{p_Y(y)}; X \perp Y \iff p_{X,Y} = p_X p_Y
Uniform on chord \|x\| \le \sqrt{1-y^2} (dependent)