Distribution drips
Distributions are easier to grasp when you can see them.
I always tell students to look first at the shape of the data they're examining. Visualising the distribution helps us understand what the data are saying and whether they need to be transformed before analysis.
This drips a sample of random points X, drawn from the distribution you choose. Change its parameters and the sample size and watch the shape change. It's a simple way to see the order that underlies randomness.
What are these distributions?
- Normal (Gaussian): Symmetric, bell-shaped distribution where most values cluster around the mean (μ). The standard deviation (σ) controls the spread: smaller σ = tighter cluster, larger σ = wider spread. Examples include human height, measurement errors, IQ scores.
- Uniform: Every outcome in the range [a, b] has equal probability – therefore no peaks or skews. Discrete example: rolling a die (1 to 6, each with 16.7% chance). Continuous example: randomly picking a number between 0 and 10.
- Log-normal: Right-skewed distribution where the logarithm of values is normally distributed. μ and σ describe the underlying normal distribution of the log-values. Examples include stock prices (can't go below zero but can skyrocket), particle sizes, income distributions. Note that if X is log-normal, log(X) is also normal.
- Exponential: Models the time between events in a Poisson process (e.g. machine failures, customer arrivals). The rate (λ) is the average number of events per unit time. For λ = 0.1, the average wait time is 10 units. An example is the time until a light bulb fails – most will burn out early but some last much longer. The probability of an event decreases exponentially over time.
- Poisson: Counts of events in a fixed interval when they arrive independently at a steady average rate (λ) (e.g. goals in a football match, outages on a network in a month). It pairs with the exponential – one counts the events, the other times the gaps between them.
- Binomial: Number of successes in n independent yes-or-no trials, each with probability p of success: (e.g. heads in 20 coin tosses, faulty items in a batch of 100). As n grows, the shape settles towards a normal distribution.
- Beta: Lives between 0 and 1, so it suits proportions and probabilities (e.g. the share of a vote, how certain we are of something). The two shape parameters (α, β) bend it: equal values are symmetric, α smaller than β piles up on the left and values below 1 push it into a U.
- Bates: The mean of n uniform random numbers. With n = 1 it is uniform, with 2 a triangle and by 3 or 4 it is already a bell. This is the central limit theorem at work: averages of almost anything end up normal.
- Two normals: Not a distribution so much as two of them, sampled half and half. This is what a column of data looks like when two populations are hiding in it. A reminder of why we should look at the shape of data before trusting the average.
I built this with the d3-random library.