CSM Animation Zoo
Interactive animations I have built for my Cambridge course Computer Systems Modelling. Each one runs in the browser; no installation is needed. The cards below say what each animation shows, what to try, and which ideas from the course it illustrates.
Sampling by Inversion
Shows: how to generate samples from any distribution using the inverse-CDF method, X = F−1(U).
How it works: Sketch a density f with the mouse (or pick a preset: bimodal, piecewise constant, triangular, truncated exponential, uniform). The page computes the CDF F as you draw. Each sample picks u ~ U(0,1) on the vertical axis of F, runs across to the curve, and drops to x = F−1(u). A histogram of the samples builds up beneath, and converges to f.
Try this: Draw one sample at a time to follow the path, then switch off animation and draw batches. Note how steep parts of F catch many values of u while flat parts catch almost none.
Concepts: CDF and its inverse · inverse transform sampling · empirical distribution · sample mean vs. E[X]
Confidence Interval Lab
Shows: how the sample mean, sample variance and 95% confidence interval behave, and why the central limit theorem makes intervals work for any population.
How it works: In three steps. (1) Sketch a population density; its true mean μ and variance σ² are computed exactly. (2) Draw one run of n samples and watch X̄n, Sn² and the t-interval settle as samples arrive, with the interval narrowing like 1/√n. (3) Repeat for hundreds or thousands of runs: the sample means pile up as N(μ, σ²/n), and about 95% of the intervals contain μ.
Try this: Use a skewed population with small n (say 5) and see coverage fall short of 95%; then increase n and watch it recover. Compare a bimodal population with a uniform one: the histogram of means looks normal either way.
Concepts: sample mean and variance · Student’s t interval · coverage · central limit theorem · standard error
Random Walk
Shows: sample paths of a birth–death Markov chain: a random walk that steps up with probability p and down with probability 1 − p, held at its boundaries.
How it works: Choose p, a starting state, the number of steps, and either a finite chain on 1 … N or a semi-infinite chain on 1, 2, 3, …. Each press of Run adds a new trajectory in a new colour, so runs can be compared side by side. For the semi-infinite chain, a dashed line shows the expected drift s0 + (2p − 1)t.
Try this: On the semi-infinite chain, compare p = 0.4, 0.5 and 0.6. For p > ½ the walk escapes and tracks the drift line (transient); for p ≤ ½ it keeps returning to state 1 and the line is misleading (recurrent). On a finite chain, watch where the walk spends its time as p moves away from ½.
Concepts: Markov chains · reflecting boundaries · drift and linearity of expectation · transience vs. recurrence · √t spread of trajectories