Transformations of Probability Densities
Formal
If we have a continuous random vector with a known probability density function (PDF) , and we pass it through an invertible, differentiable non-linear transformation , what is the new PDF ?
Because total probability mass must be conserved (it must sum to 1), stretching or compressing the space changes the density. The scaling factor for this change in volume is the determinant of the Jacobian matrix.
The PDF of the transformed variable is:
Alternatively, using the Jacobian of the forward transformation :
Why the absolute value?
The determinant can be negative (indicating a reflection/inversion of the space). However, probability density must be strictly non-negative , so we take the absolute value of the volume scaling factor.
Intuition
Imagine spreading 1 kg of dough (probability mass) over a 1x1 meter square table (the sample space). The density is 1 kg/m².
If your transformation stretches the table to be 2x2 meters, the same 1 kg of dough is now spread over 4 m². The new density must drop to 0.25 kg/m².
The Jacobian determinant tells you exactly how much the “table” was stretched locally at every single point. If a region was expanded (Jacobian > 1), the probability density there must decrease. If a region was compressed (Jacobian < 1), the probability density there must spike.
ML Applications
- Normalizing Flows — A class of generative models that start with a simple distribution (like a standard Gaussian) and apply a sequence of invertible transformations to warp it into a highly complex data distribution (like images of faces). The loss function directly optimizes equation (1).
- Reparameterization Trick (VAEs) — In Variational Autoencoders, we cannot backpropagate through random sampling. We use a transformation (where ) to make sampling differentiable. Because this is a linear transformation of a Gaussian, the density of is simply analytically — the change-of-variables formula is not needed here. The formula in this note is what enables Normalizing Flows, which compose a sequence of nonlinear invertible transformations where the Jacobian determinant must be tracked explicitly at each step.
- Sampling from non-standard distributions — Inverse Transform Sampling uses the CDF as the transformation function to turn uniform noise into any target distribution.
Connections
- Forward Links:
- Backward Links: Random Variables, The Jacobian Determinant, Gradients of Vector-Valued Functions