Change of Variable for a Density Explained with Worked Examples

If with monotonic, then . Probability mass is conserved, so the density is scaled by how the map stretches the axis.

Write 2x or 2*x to multiply, ^ for powers, and ; between simultaneous equations. You can also type factor, expand, derivative of, integrate … from a to b, limit … as x->0 or 15% of 80.

Try an example

Before you start

This page is easier if you are comfortable with:

What Change of variable for a density means

Let and . Then , and , an exponential density (the exponential distribution); for , . With and : , , so , equal to 1 at .

For a linear change with : , , so , which is the density; at it is (the normal density, linear transformations). The derivative of the inverse is from the inverse function derivative.

When is not one-to-one, add the contributions of each branch. In several variables the derivative is replaced by the Jacobian determinant (the Jacobian, joint densities). The method generates random numbers from a given distribution (inverse transform sampling), used in Monte Carlo simulations.

What is it used for?

When a random variable is transformed, its density is rescaled by the derivative of the inverse transformation.

How to use change of variable for a density

  1. Solve for .
  2. Differentiate: .
  3. Form .
  4. State the range of .

Graph

Density 1/(2√y) of Y = X² when X is uniform on (0, 1)f(0.25) = 10.10.20.30.40.50.60.70.80.9100.511.52Density 1/(2√y) of Y = X² when X is uniform on (0, 1)ydensityf_Y(y) = 1/(2√y)Graph with x from 0.05 to 1 and y from 0 to 2.4. Shows the curve f_Y(y) = 1/(2√y); point f(0.25) = 1 at (0.25, 1).

Squaring crowds the probability near zero, so the density is high there.

Worked examples

These examples are worked by hand, step by step, so you can compare your own working.

Example 1: exponential from uniform

For , , find .

Worked example
Answer
0.27070.2707
  1. x
  2. f_Y
  3. At y = 1

Example 2: the square

For , , find .

Worked example
Answer
11
  1. f_Y
  2. At 0.25

Example 3: a linear map

For , , find .

Worked example
Answer
0.19950.1995
  1. f_Y
  2. φ(0)

Special cases

A few situations come up again and again. Knowing them saves time and helps you spot answers that cannot be right.

Y = 2X + 1, X ~ U(0, 1)

f_Y = 1 × 1/2

0.5 on (1, 3).

Y = X², X ~ U(0, 1), y = 0.25

1/(2√y)

1.

Y = e^X, X ~ Exp(1), y = 2

f_X(ln y)/y = e^(−ln 2)/2

0.25.

Check

density integrates to 1

0.5 × 2 = 1.

Word problems

For Y = g(X) monotonic, f_Y(y) = f_X(g⁻¹(y))|d g⁻¹/dy|. Probability mass is conserved, so the density is rescaled by the stretch of the map.

Linear

Y = 2X + 1, X ~ U(0, 1). Find f_Y.

  1. 1 × |dx/dy|1/2
  2. Check: ✓0.5

Square

Y = X², X ~ U(0, 1). Find f_Y(0.25).

  1. 1/(2 × 0.5)
  2. Check: ✓1

Exponential map Higher

Y = e^X, X ~ Exp(1). Find f_Y(2).

  1. e^(−ln 2)/2
  2. Check: ✓0.25

Normalisation Higher

Check the area of the density 0.5 on (1, 3).

  1. 0.5 × 2
  2. Check: ✓1

Common mistakes

Forgetting the Jacobian

f_X(g⁻¹(y)) ✗

times |dx/dy| ✓

Scaling.

Non-monotonic g

single branch ✗

sum over branches ✓

e.g. Y = X².

Wrong support

old range ✗

transformed range ✓

Y ∈ (1, 3).

Using dy/dx

multiply by g′ ✗

divide by g′ ✓

Inverse derivative.

Exam tips

  1. Invert y = g(x).
  2. |dx/dy| factor.
  3. Transform the support.
  4. Check area = 1.
  5. Non-monotonic: sum branches.

Practice questions

Try each one on paper, then open the answer. Use the solver above to see the full working.

1. Y = 3X, X ~ U(0, 1): f_Y Foundation

0.3333

2. Y = X², f_Y(0.16) Foundation

1.25

3. Y = 4X + 2, X ~ U(0,1): f_Y Foundation

0.25

4. Y = e^X, X ~ Exp(1), y = 4 Higher

0.0625

5. Y = X², f_Y(1) Higher

0.5

6. Area: 0.25 on (0, 4) Higher

1

Practice generator

Unlimited fresh questions with instant marking. Choose a level, work it out on paper, then type your answer.

Solve: …

Key terms

Change of variable
Density of g(X).
Jacobian
Monotonic function
Always increasing or decreasing.
Support
Values with positive density.
Inverse function
g⁻¹.
Mass conservation
Total probability 1.

Frequently asked questions

How do I find the density of Y = g(X)?

f_Y(y) = f_X(g⁻¹(y))|dg⁻¹/dy|.

Why the derivative?

The map stretches or squeezes the axis.

What if g is not monotonic?

Add contributions of each branch.

How do I check?

The density must integrate to 1.

Which page covers joint densities?

joint, marginal and conditional densities.

Which page covers the Poisson process?

Poisson process.

More in Advanced statistics and stochastic processes and the formula sheets.