Interactive element. The change of variables describes how the distribution p(x) associated with a random variable x changes under a function f that yields a new random variable y = f(x). Drag the nodes to adjust the cubic spline and see how the pushforward distribution (blue) changes in response to the function.

Change of variables

The change of variables formula describes what happens to a pdf p(x) when its associated random variable x is transformed with a function f, which yields a new random variable y = f(x) associated with a pushforward pdf p(y):

p(f(x)) = p(x) / |∂ f(x)| 

In words: the probability density p(y) after the transformation depends on the probability density before the transformation (p(x)) corrected for any stretching or squeezing induced by the transformation (1 / |∂ f(x)| ).

Observe that the steeper the gradient of f is, the smaller 1 / |∂ f(x)| and the lower the pushforward density becomes. Conversely, if the gradient of f is flat, the correction term inflates the density.

Drag your mouse over the graph and observe how the function stretches or squeezes the red input interval.