Mathwords logoMathwords

Inverse Transform Sampling — Definition, Formula & Example

Inverse transform sampling is a way to turn random numbers between 0 and 1 into random values that follow any distribution you choose. You feed each uniform random number into the inverse of the target distribution's cumulative distribution function (CDF).

Let FF be a cumulative distribution function and define its generalized inverse F−1(u)=inf⁡{x:F(x)≥u}F^{-1}(u) = \inf\{x : F(x) \ge u\} for 0<u<10 < u < 1. If U∼Uniform(0,1)U \sim \text{Uniform}(0,1), then X=F−1(U)X = F^{-1}(U) has CDF FF. The reason is that F−1(u)≤xF^{-1}(u) \le x exactly when u≤F(x)u \le F(x), so P(X≤x)=P(U≤F(x))=F(x)P(X \le x) = P(U \le F(x)) = F(x).

Key Formula

X=F−1(U),U∼Uniform(0,1)X = F^{-1}(U), \qquad U \sim \text{Uniform}(0,1)
Where:
  • UU = A random number drawn uniformly from the interval (0, 1)
  • FF = The CDF of the distribution you want to sample from
  • F−1F^{-1} = The inverse (or generalized inverse) of F, which maps a probability back to a value
  • XX = The generated sample, which has CDF F

Worked Example

Problem: A store models the distance, in miles, from the store to a delivery address with the density f(x)=x8f(x) = \frac{x}{8} for 0≤x≤40 \le x \le 4. Your computer gives you two uniform random numbers, u1=0.25u_1 = 0.25 and u2=0.81u_2 = 0.81. Use inverse transform sampling to turn them into two simulated delivery distances.
Step 1: Find the CDF by integrating the density from 0 to x.
F(x)=∫0xt8 dt=x216,0≤x≤4F(x) = \int_0^x \frac{t}{8}\,dt = \frac{x^2}{16}, \quad 0 \le x \le 4
Step 2: Set the CDF equal to u and solve for x. Keep the positive root, because distances in this model lie between 0 and 4.
u=x216  ⟹  x=F−1(u)=4uu = \frac{x^2}{16} \implies x = F^{-1}(u) = 4\sqrt{u}
Step 3: Substitute each uniform number into the inverse CDF.
40.25=4(0.5)=2,40.81=4(0.9)=3.64\sqrt{0.25} = 4(0.5) = 2, \qquad 4\sqrt{0.81} = 4(0.9) = 3.6
Answer: The simulated delivery distances are 2 miles and 3.6 miles. Check: F(2)=416=0.25F(2) = \frac{4}{16} = 0.25, which matches u1u_1.

Why It Matters

Computer random number generators produce uniform values on (0, 1), so you need a method like this to simulate anything else. In queueing and Monte Carlo simulations, it gives exponential wait times through X=−ln⁡(1−U)/λX = -\ln(1-U)/\lambda. Courses in probability, simulation, and actuarial science use this formula constantly.

Common Mistakes

Mistake: Treating F−1(u)F^{-1}(u) as the reciprocal 1F(u)\frac{1}{F(u)}, or plugging uu into the density ff instead of inverting the CDF.
Correction: F−1F^{-1} is the inverse function. Solve the equation u=F(x)u = F(x) for xx. The result is a value of the random variable, and it must lie in the distribution's support. In the example, x=4ux = 4\sqrt{u} always falls between 0 and 4.

Related Terms