Draw random waiting times and sort them into bins. Watch the bars settle onto a smooth curve as the draws pile up.
From bars to a smooth curve
Waiting times drawn from the exponential law with rate 1 (seed 2400); bars scaled to area.
Waiting times: draws from the exponential law fall into 10 bins 0.5 wide.
Describe this picture
One panel: seeded random waiting times (seed 2400) fall into bins along an axis from 0 to 5. Each bar’s height is its count divided by the number of draws times the bin width, so the bars have total area 1, apart from the few draws beyond 5, which fall off the axis. The clip first drops 100 draws into 10 bins 0.5 wide: a rough staircase with area 0.980, two draws lying beyond 5. The same 100 then split into 40 bins 0.125 wide, taller and rougher. Then 4900 more pour in, the bar tops settle, and a smooth falling curve labelled “exact density”, , is drawn over them; the caption gives the area, 0.994, with 32 of the 5000 draws beyond 5. Readouts give the number of draws, the bin width and the bars’ area. After the clip a slider, “Bin width”, sets the width to 0.05, 0.1, 0.125, 0.2, 0.25, 0.5 or 1, widths that fit 0 to 5 exactly; the steps get finer or coarser, the shape and the area stay.
Bars that become a curve
A die has six values you can list. A waiting time does not: the bus can come after 2 minutes, 2.1, 2.13, any number at all. A random variable that can take any value in a range is continuous. No list of values with their chances can describe it, so I need something else. The picture shows what.
Each bar’s height is its count divided by (number of draws × bin width). That makes a bar’s area, height times width, equal to its count divided by the number of draws: the share of draws in that bin. All the bars together have area 1.
Now make the draws many and the bins narrow. The bar tops settle onto a curve, the same curve whatever the bin width. That curve is the density of , written . Here it is for .
A bar shows the curve’s average over its width. The first bar, from 0 to 0.5, averages ; the first bar of width 0.125 averages ; the curve itself starts at 1. Narrower bins follow the curve more closely.
Probability is area
Bar areas are shares, so in the limit the probability that lands between and is the area under the density there:
Every draw lands somewhere, so the total area is 1, and a density is never negative.
A single exact value is a strip of width zero, so its area is zero: . That does not mean a wait of exactly 1 minute is impossible: such a wait can happen, but the chance of hitting 1.000… exactly is zero. For the same reason, and give the same answer here.
Watch out
The height of a density is not a probability. For this curve , yet . Height is probability per unit of width, so it can even rise above 1: a density that is flat at height 2 between 0 and 0.5 still has area .
The distribution function
The distribution function is the same as for discrete variables, the chance of landing at or below :
It climbs smoothly from 0 to 1. Its slope is the density, : where the density is high, climbs fast.
For the curve above, for . The chance of landing above is then . This is called the survival function, because for lifetimes it is the chance of lasting past .
The median is the value with half the area on each side, where . Here gives .
Means and variances by integrals
The mean and the variance work as in Expected value and Variance and standard deviation, with the sum over values replaced by an integral over the density:
The uniform law. A variable spread evenly between and has the flat density there and 0 elsewhere. I write it . By symmetry its mean is the middle, . Its variance, the integral of the squared distance from the middle over a width , is
The exponential law. The waiting times in the picture follow the exponential law with rate , :
The picture used . Here is a rate, events per unit of time; in the linear algebra course the same letter is an eigenvalue. Integrating by parts,
A second integration by parts gives , so . The standard deviation equals the mean, . Its distribution function is .
Worked example
1. Areas under . For , read as “follows”:
2. Waiting for a bus. A bus comes every 10 minutes and you arrive at a random moment, so your wait is minutes. The chance of waiting more than 7 minutes is the area from 7 to 10, . The mean wait is 5 minutes, the variance and the standard deviation minutes.
3. A light bulb. A bulb’s lifetime is exponential with mean 1000 hours, so per hour. The chance it lasts past 1500 hours is .
Now suppose it has already lasted 1000 hours. The chance it lasts past 1500 is, by Conditional probability,
the same as the chance that a new bulb lasts 500 hours. An exponential lifetime does not age: what is left of it does not depend on how long it has run. This is called being memoryless, and it is why the exponential law fits failures that strike at random, not wear-out.
Try it yourself. For , is equal to ? No: it is 0. Only areas are probabilities.
Where you’ll meet this
Waiting times. The time to the next phone call, the next radioactive decay or the next customer is often exponential: events that strike at random, at a steady rate. Random arrivals builds on it.
Lifetimes. Reliability engineers write lifetimes with densities and quote survival functions: the chance a part still works after a given time.
Measurement noise. The noise in a sensor reading takes any value in a range, so it is described by a density, most often the bell of The normal distribution.
In signal processing · rounding error is uniform
The rounding error of a quantizer is spread evenly over one step , a uniform variable, so its variance is , the formula above. Quantization and noise in the signal processing course uses exactly this. There a density is written , with a small for the random signal; here it is .
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Probability | area, total 1 | |
| One exact value | height is not probability | |
| Distribution function | ||
| Survival function | chance of lasting past | |
| Mean, variance | , | sums become integrals |
| Uniform | density ; mean ; variance | rounding error |
| Exponential | ; mean ; variance | memoryless |