Probability Distributions Lab

Uniform random numbers go in; any distribution comes out through its inverse CDF.

Presets

Distribution

Sampling

Click or drag on the middle plot to choose a uniform number u yourself and read off x = F-1(u).

Moments: sample vs theory

Independent checks

Experiment

If the samples really follow the distribution, a 5 % test should reject about 5 % of the time, no more and no less.
The science

Inverse-CDF sampling. If U is uniform on (0,1) and F is a distribution function, then X = F-1(U) has distribution F, because P(X ≤ x) = P(U ≤ F(x)) = F(x). For discrete families the generalised inverse F-1(u) = min{k : F(k) ≥ u} is used. Exponential: x = −ln(1−u)/λ; Weibull: x = λ(−ln(1−u))1/k. Normal and Gamma have no closed form, so the inverse is found by bisection on the CDF (built on the regularised incomplete gamma function, erf(x) = P(1/2, x2)).

Moments. Mean, variance, skewness and excess kurtosis from the samples are compared with the exact values; their sampling error shrinks like 1/√N (mean) so the running-mean plot funnels into the theoretical value inside a ±3σ/√N envelope.

Kolmogorov-Smirnov. D = max|FN(x) − F(x)| between the empirical and the exact CDF; reject at 1 % if √N D > 1.628 (asymptotic, conservative for discrete families). Chi-square compares bin counts O with expected E: χ2 = ∑(O−E)2/E, p-value from the chi-square distribution (itself a Gamma). With a true model the p-value is uniform on (0,1), so about 5 % of runs fall below 0.05 by design: that is what the experiment button measures.

Independent sampler. Normal is also drawn with Box-Muller, Gamma with Marsaglia-Tsang, Binomial as a sum of Bernoulli trials, Poisson with Knuth's multiplication method, Geometric by counting trials; a two-sample KS test checks they agree with the inverse-CDF samples. Uniform, Exponential and Weibull rely on the other checks (round trip, numerical integrals, derivative of the CDF).

Central limit theorem. The average of m i.i.d. draws has mean μ and variance σ2/m and tends to a normal law; with m > 1 the plots compare against that normal approximation, not an exact law, so the check shows how fast the approximation works (slowly for the skewed Exponential, almost at once for Uniform).

Simplifications. The generator is a 32-bit mulberry generator, not a cryptographic one. Discrete KS is conservative. Chi-square bins with expected count below 5 are pooled. All constants are exact formulas, nothing is empirical.