Day 9's four distributions were all about counting: how many successes, how many trials, how many events. Plenty of real quantities aren't counts. A delivery doesn't take a whole number of minutes, a server's response time isn't an integer, and a person's height isn't a count of anything. These are measurements, and they can take any value in a range. Today's distributions are built for them.
Three problems to keep in mind:
- A train comes every 10 minutes and you turn up at a random moment. How long will you wait?
- A shop's orders average $85. How often is an order above $120?
- Support tickets arrive at 6 per hour. How long until the next one?
From counting to measuring: a quick recap
Day 8 introduced the key idea, so here's the short version. For a continuous random variable:
- The probability of any single exact value is 0. You can only ask about ranges: not "exactly 6.4173 minutes" but "between 5 and 7 minutes".
- The distribution is described by a probability density function, f(x). Probabilities are areas under it; its height is density, not probability.
- The CDF, F(x) = P(X ≤ x), is the area to the left of x, so P(a < X < b) = F(b) − F(a). SciPy's
.cdf()does the calculus for you.
Each distribution below is just a different answer to the question "what does f(x) look like?"
1. The uniform distribution
Every value in a range is equally likely. The uniform distribution is a flat line: the same density everywhere between a lower bound a and an upper bound b, and zero outside. It's the natural model when you have no reason to favour any value in a range over another.
Worked example: waiting for a train
Trains come every 10 minutes and you arrive at a random moment, so your wait is equally likely to be anything from 0 to 10 minutes: X ~ Uniform(0, 10).
SciPy describes the uniform distribution by where it starts (loc) and how wide it is (scale), not by its two endpoints. Uniform(2, 5) is stats.uniform(loc=2, scale=3). Writing scale=5 by mistake gives you Uniform(2, 7) with no error message.
Two more places the uniform turns up:
- Rounding error. A sensor rounds to the nearest whole unit, so the error is equally likely to be anywhere from −0.5 to +0.5. Its mean is 0, so rounding doesn't push readings up or down on average; it just adds a little noise, with variance 1/12 ≈ 0.083.
- Random assignment in experiments. Python's
random.random()and NumPy'srng.random()both draw from Uniform(0, 1). An A/B test can send a visitor to the new version when that number is below 0.5 (a 50/50 split), or below 0.1 for a 10% test group. Every visitor gets the same chance, which is what makes the comparison fair.
2. The normal distribution
The bell curve. Many measurements cluster around a central value and thin out symmetrically on both sides: adult heights, measurement errors, many biological traits. That shape is the normal distribution, also called the Gaussian after the mathematician Carl Friedrich Gauss. It's described by just two numbers: the mean μ, which sets the centre, and the standard deviation σ, which sets the spread.
z-scores: one scale for every normal distribution
Every normal distribution has its own mean and spread, but they all share one shape. To compare across them, convert a value into a z-score: how many standard deviations it sits from the mean.
A z-score of 2 means "two standard deviations above average", whether you're measuring order values in dollars or bolts in millimetres. Converting to z-scores is called standardisation, and it's the same step machine learning libraries apply to features before training many models.
IQ tests are scored so that the population has a mean of 100 and a standard deviation of about 15, with scores following a bell curve. That makes every score a z-score in disguise: an IQ of 130 is z = (130 − 100)/15 = 2. Under a normal model, about 2.3% of people score above 2 standard deviations, which is why textbooks say "about 2% score above 130", and the same share below 70.
The 68-95-99.7 rule
For every normal distribution, the share of values within a given number of standard deviations of the mean is the same:
This is why a value more than 3 standard deviations from the mean counts as genuinely unusual for normal data: only about 3 in 1,000 values land out there. (As Day 4 warned, an outlier can inflate the SD itself, so use this rule with care on messy data.)
Worked example: order values
Suppose a shop's order values are roughly normal with a mean of $85 and a standard deviation of $20: X ~ Normal(85, 20). (Real order values are often right-skewed, like Day 3's case study, so always check the shape first. More on that below.)
A $120 order is z = (120 − 85)/20 = 1.75, and only 4% of orders are that large. The last two lines run the CDF backwards with ppf, Day 8's inverse CDF: half of all orders fall between $71.51 and $98.49, and an order of $110.63 or more puts a customer in the top 10%. Grading curves, "top X%" cut-offs and percentile thresholds all work this way.
Manufacturing tolerances and "Six Sigma"
A factory machines bolts to a target diameter of 10 mm with a standard deviation of 0.05 mm, and anything from 9.85 to 10.15 mm passes inspection. Those limits are exactly 3 standard deviations either side of the target, so by the 68-95-99.7 rule about 99.73% of bolts pass, and about 2,700 in every million fail through ordinary variation alone, with nothing wrong with the machine.
In 1986 the engineer Bill Smith at Motorola introduced Six Sigma, a quality programme whose name refers to keeping the nearest specification limit six standard deviations from the process average. Its famous target is 3.4 defects per million opportunities. That number doesn't come from six standard deviations, though: the method assumes a process drifts by about 1.5 standard deviations over the long run, leaving a 4.5 standard deviation margin on one side, and the normal tail beyond 4.5σ is 3.4 per million.
Is my data actually normal?
A normal model is only as good as the fit. Let's compare two real datasets from earlier in the series: bill lengths of the 151 Adelie penguins in the Palmer penguins data (Day 6), and the 244 restaurant bills from the tips data (Day 8).
The penguins land close to 68 / 95 / 99.7, with skewness near 0. The restaurant bills are trickier: their percentages (72 / 94 / 98) look almost normal, but every one of the 14 bills more than 2 SDs from the mean is on the high side, and none on the low side. That lopsidedness, skewness 1.13, is exactly what a normal model can't capture. Two lessons: always look at a histogram, not just a few summary numbers; and for skewed, positive data like money or time, a normal model can badly misjudge the tails.
3. The exponential distribution
How long until the next event? When events happen independently at a steady average rate λ (the setting of Day 9's Poisson distribution), the waiting time between one event and the next follows an exponential distribution. It's the continuous version of Day 9's geometric distribution: a wait measured on a clock instead of counted in trials.
Worked example: support ticket arrivals
Tickets arrive at 6 per hour, so the average gap is 1/6 of an hour, or 10 minutes.
Textbooks write the exponential with a rate λ (6 per hour). SciPy's stats.expon takes scale = 1/λ, the mean wait. Writing stats.expon(scale=6) for "6 per hour" silently gives you a mean gap of 6 hours instead of 10 minutes.
Notice the median gap (6.9 minutes) is shorter than the mean (10 minutes). The exponential is right-skewed: most gaps are short, and a few long ones pull the mean up, the same pattern as Day 3's skewed data.
Memoryless, again
The exponential shares the geometric distribution's memoryless property from Day 9. If you've already waited 10 minutes for a ticket, the remaining wait has exactly the same distribution as when you started. For a component that fails at random, a part that has run for 3 years is, under this model, exactly as likely to last 4 more years as a brand-new one.
Take a component with a mean lifetime of 2.5 years (λ = 0.4 per year). P(lasts more than 4 years) = e−1.6 ≈ 20.2%. For a 3-year-old component, P(lasts to year 7 | made it to year 3) = e−2.8 / e−1.2 = e−1.6, the same 20.2%. The 3 years already served simply drop out.
That's a strong assumption. Parts that wear out get more likely to fail as they age, and for them engineers typically use other models, such as the Weibull distribution, that let the failure risk change with age. Use the exponential when events really do happen "at random", with no build-up or wear.
Radioactive decay is the textbook example of a memoryless process. Each carbon-14 atom has a constant chance of decaying in any given year, regardless of how old it is, so the time until a particular atom decays follows an exponential distribution. The half-life of carbon-14 is 5,730 years: after that long, half the atoms in a sample remain. In distribution terms, the half-life is simply the median of the exponential, ln(2)/λ. After two half-lives a quarter remain, after three an eighth. This is the clock behind radiocarbon dating.
Choosing the right distribution
| Distribution | Use it when | Parameters | E[X] | Var(X) | In SciPy |
|---|---|---|---|---|---|
| Uniform(a, b) | Every value in a range is equally likely | a, b | (a + b)/2 | (b − a)2/12 | uniform(loc=a, scale=b-a) |
| Normal(μ, σ) | Values cluster symmetrically around a centre | μ, σ | μ | σ2 | norm(loc=mu, scale=sigma) |
| Exponential(λ) | Waiting time until the next random event | λ | 1/λ | 1/λ2 | expon(scale=1/lam) |
One process, two distributions
The Poisson and exponential distributions aren't two separate ideas. They're two views of the same random process. Count the events in a fixed window and you get a Poisson distribution. Time the gaps between events and you get an exponential distribution. That's why the Poisson rate λ and the exponential mean 1/λ are reciprocals: 6 tickets per hour means an average gap of 1/6 of an hour.
A first look at the central limit theorem
Here's a claim that sounds too good to be true. Take almost any distribution, even a lopsided one like the exponential. Draw a sample, compute its average, and repeat many times. The averages will form an approximately normal distribution, whatever shape you started with, as long as the samples are big enough.
That's the central limit theorem (CLT), and it's the main reason the normal distribution shows up everywhere. A metric doesn't need to be normal itself for its average to behave like one, and averages are what most statistical methods work with. Two conditions matter: the values should be independent draws, and the original distribution should have a finite variance (a few extremely heavy-tailed distributions break the rule).
Averaging dice
Start with the flattest distribution possible: one fair die, where each face from 1 to 6 is equally likely. Now average 2 dice, then 5, then 30.
The mean stays at 3.5 throughout. What changes is the shape and the spread. "Excess kurtosis" measures how far a distribution's shape is from a normal one in its peak and tails (a normal distribution scores 0). A single die scores about −1.27, very flat. Averages of 30 dice score about −0.06, almost exactly normal. The spread also shrinks, by a factor of √n: the SD of one die is 1.71, and of an average of 30 dice, 1.71/√30 ≈ 0.31.
A harder test: a badly skewed start
Averaging 40 values cut the skewness from 2.0 to about 0.3, and the spread of the averages matches the σ/√n prediction almost exactly. That quantity, the standard error, is the foundation of Day 11. A common rule of thumb says samples of 30 or more are usually enough for the CLT to kick in, but heavily skewed data, like this, needs more.
In 1874 the scientist Francis Galton built a device to demonstrate this idea, now called a Galton board. Balls drop through rows of pegs, bouncing left or right at each one, and pile up in bins at the bottom. Each ball's final position is the sum of many small random left-or-right steps, a binomial count, and the piles form a bell curve. Galton wrote about it in his 1889 book Natural Inheritance. Sums and averages of many small random effects tend towards the normal: that's the central limit theorem, built from wood and pins.
Back to DeliverFast: three continuous questions
Day 9 ended with an ops meeting at DeliverFast, the food delivery startup. The team is back with three questions about measurements rather than counts.
"How far do our deliveries travel?" In one zone, suppose distances are roughly uniform between 1 and 6 km: Uniform(1, 6). Mean 3.5 km; 20% are under 2 km and 20% over 5 km, which helps set fair delivery-fee tiers.
"How often do we break the 40-minute promise?" Delivery times average 28 minutes with an SD of 6, and the histogram looks roughly bell-shaped: Normal(28, 6). A 40-minute delivery is z = 2, so about 2.3% of deliveries break the promise through ordinary variation alone. (If the histogram had a long right tail, a normal model would understate this.)
"At our busiest restaurant, how long between new orders?" Orders arrive with an average gap of 4 minutes: Exponential with mean 4. P(next order within 2 minutes) ≈ 39.3%; P(a 10-minute lull) ≈ 8.2%, long enough for the kitchen to catch up.
Same company, same kind of meeting as Day 9, but every question this time is about a distance or a duration. Recognising the shape of the process is still the real skill.
What comes next
Every example so far assumed we already knew the true parameters: p, λ, μ, σ. Real data science almost never works that way. You don't know the true conversion rate or the true average delivery time. You have a sample, and you want to work back to what's true about the whole population. That's statistical inference, and it's where the series goes next. The central limit theorem you met today is what makes most of it possible.
Key takeaways
- Continuous variables are measured, not counted, and probabilities come from areas under a density curve.
- Uniform: every value in a range equally likely. Normal: a symmetric bell set by μ and σ, read through z-scores and the 68-95-99.7 rule. Exponential: the memoryless wait until the next random event, the twin of the Poisson.
- Check the fit. Real data, especially money and time, is often skewed, and a normal model can misjudge the tails badly.
- Watch SciPy's parameters: uniform uses loc and width, exponential uses scale = 1/λ.
- The central limit theorem makes averages approximately normal, even when the data isn't.
Quick check
Five questions to test whether this stuck. The answers are one click away.
A number is drawn uniformly between 0 and 100. What's the probability it's exactly 50?
0. For any continuous random variable, any single exact value has probability 0. Only ranges, such as "between 49.5 and 50.5" (1%), have non-zero probability.
Delivery times are roughly normal with a mean of 28 minutes and an SD of 6. About what share take between 22 and 34 minutes?
About 68%. 22 and 34 are each 1 standard deviation from the mean, so this is the 68-95-99.7 rule's first band.
Requests arrive at 30 per minute. A colleague writes stats.expon(scale=30) to model the gap between requests. What's wrong?
SciPy's scale is the mean gap, 1/λ, not the rate. 30 per minute means a mean gap of 1/30 of a minute (2 seconds), so it should be stats.expon(scale=1/30). As written, it models an average gap of 30 minutes.
Why are the Poisson rate and the exponential mean reciprocals of each other?
They describe the same process from two angles. If events happen at λ per hour (Poisson), the average wait between them is 1/λ hours (exponential). More events per hour means shorter gaps.
You take many samples of size 50 from a heavily skewed population and plot their means. Will the plot still look heavily skewed?
Much less so. By the central limit theorem, the distribution of sample means moves towards normal as the sample size grows, whatever the population's shape. In this article's simulation, averaging 40 values cut the skewness from 2.0 to about 0.3.
Part III begins: sampling, the central limit theorem in depth, standard errors, confidence intervals and the bootstrap, or how to learn the truth about a population from a sample.