Skip to main content

Transformations, quantiles and inverse sampling

What this concept is​

A transformation changes a random variable, not just its units. Begin with the CDF: F_Y(y)=P(g(X)≤y). For a differentiable strictly monotone transformation with differentiable inverse, the density uses the absolute inverse derivative wherever the formula is valid.

Why it matters here​

This connects calculus to simulation and prevents incorrect percentile and density conversions. Finish CAL1–CAL6 before this cluster.

Concrete example​

If X is uniform on [0,1] and Y=X², then F_Y(y)=sqrt(y) on [0,1], zero below and one above. Its density is 1/(2sqrt(y)) for 0<y<1. The density grows without bound near zero but its improper integral is 1. The mean is ∫₀¹ x² dx=1/3, not (E[X])²=1/4.

Common confusion / misconception​

One-to-one formulas cannot be applied blindly to squaring across negative and positive inputs. A nonlinear transform of a mean is generally not the mean of the transform.

How to use it​

For an exponential rate λ>0, F(t)=1−exp(−λt) on t≥0. Solve u=F(t): Q(u)=−ln(1−u)/λ for 0≤u<1. If U is ideal continuous uniform, P(Q(U)≤t)=F(t), which proves the model transformation. In code use −log1p(−u)/λ to avoid cancellation for tiny u; reject u=1 rather than silently returning a finite tail. Finite pseudorandom generators approximate this ideal and cannot produce every real tail value.

Check yourself​

Why is Q(0)=0 but Q(1) not a finite sample? What is the median for rate 2?

Mini drill or application​

For Y=3X+2 with X uniform on [0,1], derive support [2,5], density 1/3 and CDF (y−2)/3 on the support. For exponential rate 2, the median is ln(2)/2. Explain why a density needs a scale factor when changing units.

Read this only if stuck​

Primary source support. See the extension guide for practice, scope and evidence requirements. Local examples and lab code are original.