Brief
Fake data is useful everywhere: for tests, for demos, and for checking that a method recovers what you put in. The trick behind most random generators is short. If is uniform on and is the CDF of the distribution you want, then has exactly that distribution. This is inverse-CDF sampling, and in this project you build a generator for ten distributions with it.
A distribution is described by its PDF or its CDF . For the exponential with rate , , so . When there is no formula for , as for the normal, you integrate the PDF numerically and invert the table.
To prove a sampler works, compare its samples with the target. The Kolmogorov–Smirnov (KS) test measures the largest gap between the empirical CDF of your samples and the true one: . A small gives a large p-value. Keep in mind that a correct sampler still fails the test 5% of the time at the 5% level. That is what the level means. You will also check the expectation and variance against their formulas and watch the central limit theorem appear.
DATA · none needed
Objectives
Read-only. Log in to update progress.
VICTORY CONDITIONS
- All 10 samplers pass scipy.stats.kstest at the 5% level (p above 0.05) with 10,000 samples and a fixed seed. Record the count with `python tools/mlarena.py record BM-24 "<passed>/10"`.
- Your KS statistic D matches scipy's within 1e-12 for every distribution.
- Over 200 different seeds, about 5% of runs fail at the 5% level, as they should for a correct sampler.
Side quests
Terms in plain words
- The probability density function f(x). The area under it between a and b is the chance a value lands between a and b.
- CDF
- The cumulative distribution function F(x), the chance a value is at most x. It rises from 0 to 1 and is the integral of the PDF.
- Expectation
- The long-run average of a random variable, the sum (or integral) of each value times its probability.
- Variance
- The expected squared distance from the mean. Its square root, the standard deviation, measures the typical spread.
- Central limit theorem
- The average of many independent draws is close to normally distributed, whatever the original distribution, as long as its variance is finite.