Simulating Random Observations

Use the inverse transform method to simulate observations from a continuous distribution: given a uniform draw u on [0,1], solve F(x) = u for x, where F is the target CDF.

Step 1 of 119%

Tutorial

The Inverse Transform Method

A computer can easily generate uniform random numbers on [0,1].[0,1]. To simulate a random observation from any other continuous distribution, we use the inverse transform method:

  1. Generate uu from Uniform(0,1).\text{Uniform}(0,1).
  2. Solve F(x)=uF(x) = u for x,x, where FF is the CDF of the target distribution.

The resulting value xx is a random observation from F.F. This works because if UUniform(0,1),U \sim \text{Uniform}(0,1), then

P(F1(U)x)=P(UF(x))=F(x),P(F^{-1}(U) \leq x) = P(U \leq F(x)) = F(x),

so F1(U)F^{-1}(U) has CDF F.F.

Example. Let XX have CDF F(x)=x3F(x) = x^3 for x[0,1].x \in [0,1]. To simulate X,X, we solve u=x3u = x^3 for x:x{:}

x=u1/3.x = u^{1/3}.

If the computer produces u=0.064,u = 0.064, then the simulated observation is

x=(0.064)1/3=0.4.x = (0.064)^{1/3} = 0.4.
navigate · Enter open · Esc close · ⌘K/Ctrl K toggle