Change of Variables
Probability and Distributions
Given a random variable X with density p_X, what is the density of Y = f(X)? The answer is the change of variables formula: for a smooth, invertible f, p_Y(y) = p_X(f^{-1}(y)) left| frac{df^{-1}}{dy} right|. The Jacobian factor accounts for how f stretches or compresses probability density — concent
When with invertible, .
Without change of variables, normalizing flows do not exist as a model class — and many MCMC tricks lose their justification.
Given a random variable with density , what is the density of ? The answer is the change of variables formula: for a smooth, invertible , . The Jacobian factor accounts for how stretches or compresses probability density — concentrations of probability move with the inverse stretch.
In higher dimensions, this becomes , where is the Jacobian matrix of the inverse. Equivalently, using the forward Jacobian: where . Either form says: volume scaling of $f$ must be corrected so total probability stays 1.
The formula requires to be a bijection (one-to-one and onto on the relevant domain) and to be smooth enough for its Jacobian to exist. If is not invertible — think for — you sum contributions from all preimages. If collapses dimensions (e.g., a rank-deficient transformation), you cannot recover a density on ; instead, lives on a lower-dimensional manifold.
Change of variables shows up throughout probabilistic ML. Deriving the distribution of a sum, ratio, or transformation of known variables (e.g., for Gaussian gives a log-normal). Converting between scale parameters (when modeling vs or ). Any time we substitute a parameterization, the Jacobian keeps the probabilities honest.
The marquee application is normalizing flows: stack a sequence of invertible transformations to map a simple base distribution (standard Gaussian) to a complex target. Each layer contributes a log-det-Jacobian term, and the log-likelihood of the target becomes . Flows are the clearest modern use of change of variables — invertibility and tractable Jacobians are the whole design constraint.
Worked example — log-normal from Gaussian: If and , then with , so for . The Jacobian factor is essential — dropping it would give a non-normalizable density. This is why normalizing flows track every term.
Exercises
Put your understanding to the test. Score + streak + speed all count.
Confirm you've got it
3 quick questions. Get 2 right to mark this lesson complete.