Module 3: Distributions · Lesson 3.1 · about 20 min
Random variables and distributions
A random variable is a number decided by chance; its distribution lists what values it can take and how likely each is. Discrete and continuous, probability mass and density, and the mean and variance of a distribution.
Module 3 · about 20 minutes · school maths. You’ll be able to say what a random variable and its distribution are, tell discrete from continuous, and compute the mean and variance of a simple distribution.
In everyday terms: before a customer walks in, the number of items they will buy is unknown, but not unknowable: from experience, 40 % buy one, 30 % two, and so on. That table of chances is the distribution.
1. Numbers decided by chance
A random variable is a number whose value depends on chance: the number of orders in the next hour, tomorrow’s sales, whether the next visitor buys (1) or not (0), how long the next call lasts. Before it happens, you can’t know the value, but you can describe which values are possible and how likely each one is. That description is the variable’s distribution.
Distributions are the backbone of the rest of the course. A test (Module 6) asks “how likely is this result if nothing changed?”, which needs the distribution of the result when nothing changed.
2. Discrete and continuous
- Discrete variables take separate values, usually counts: items in a basket, complaints per day, a yes/no outcome. Their distribution is a probability mass function (PMF): a probability for each value, and they add up to 1.
- Continuous variables can take any value in a range: time, weight, revenue (near enough). Any single exact value has probability 0, so we use a probability density function (PDF), a curve whose area over an interval is the probability of landing in it. The total area is 1.
The cumulative distribution function (CDF), , works for both: the chance of being at or below . Percentiles (Lesson 1.5) are read off the CDF.
The dots are the exact PMF of the dice total, found by counting combinations. The bars are what you get by rolling. With more rolls, the bars match the dots: a distribution is what the data would look like in the long run.
3. The mean and variance of a distribution
A distribution has its own mean (expected value, Lesson 2.3) and variance:
For continuous variables the sums become integrals, but the meaning is the same: the long-run average and the long-run spread.
Two rules analysts use all the time, for independent variables and and constants , :
Variances add for independent variables, standard deviations do not. That is why the spread of a sum or average grows more slowly than you might expect, the key to Module 4.
- X
- The random variable: the number we will see, such as items in the next basket.
- P(X = x)
- For counts: the chance of exactly x. All of them add up to 1.
- Density f(x)
- For measurements: probability is the area under the curve between two values, not the height.
- μ = Σ x·P(x)
- The mean of the distribution: the long-run average of X.
- σ² = Σ (x − μ)²·P(x)
- The variance of the distribution: the long-run average squared distance from μ.
- Physical meaning
- A distribution is a recipe for data. Your real data are one batch cooked from it; statistics works backwards from the batch to guess the recipe.
“A density of 2 means a 200 % chance.” For a continuous measurement, the height of the curve is not a probability. Only areas are. A narrow curve can be taller than 1 as long as its total area is 1.
Watch it happen, one step at a time:
Maths and principle
Principle: a distribution is the long-run pattern of a chance quantity; data is a sample from it.
Equations: PMF , PDF with , CDF . Mean ; variance .
Try it: one die has mean 3.5 and variance 35/12 ≈ 2.92. What are the mean and variance of the total of 2 dice? (7 and 5.83: both double, because they add for independent dice.) The SD goes from 1.71 to 2.42, up only by √2.
4. Worked example
Made-up numbers. Basket sizes at a corner shop:
| Items x | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| P(X = x) | 0.4 | 0.3 | 0.2 | 0.1 |
- Check: 0.4 + 0.3 + 0.2 + 0.1 = 1. ✓
- Mean: 1(0.4) + 2(0.3) + 3(0.2) + 4(0.1) = 0.4 + 0.6 + 0.6 + 0.4 = 2 items.
- Variance: (1−2)²(0.4) + 0²(0.3) + 1²(0.2) + 2²(0.1) = 0.4 + 0 + 0.2 + 0.4 = 1.0; SD = 1 item.
- CDF at 2: P(X ≤ 2) = 0.7, so 70 % of baskets have 2 items or fewer.
- If items cost $3 each plus a $1 bag fee: E[3X + 1] = 3(2) + 1 = $7, SD = 3 × 1 = $3.
5. Practice
- Is “number of website errors today” discrete or continuous? “Server response time”?
- P(X = 0) = 0.5, P(X = 10) = 0.5. Find the mean and SD.
- Daily sales have mean $2,000 and SD $300, independent across days. What are the mean and SD of a 4-day total?
Answers
- Discrete (a count); continuous (a time).
- Mean 5; variance 0.5(25) + 0.5(25) = 25; SD 5.
- Mean $8,000. Variance 4 × 300² = 360,000, SD $600 (not $1,200).
Try it on your own data: the probability distribution explorer draws the PMF, PDF and CDF of the common distributions and reads probabilities off them.
New words: random variable, distribution, discrete, continuous, probability mass function, probability density function, cumulative distribution function.
- A random variable is a number decided by chance; its distribution lists values and chances.
- Discrete variables have probabilities for each value; continuous ones have densities, and areas are probabilities.
- Mean of a distribution: Σ x·P(x). Variance: Σ (x − μ)²·P(x).
- Data are a sample from a distribution; statistics guesses the distribution from the data.
Check yourself
Sources
- OpenIntro Statistics, 4th edition (Diez, Cetinkaya-Rundel, Barr), Section 3.4 Random variables https://www.openintro.org/book/os/
- NIST/SEMATECH e-Handbook, 1.3.6 Probability Distributions https://www.itl.nist.gov/div898/handbook/eda/section3/eda36.htm
Your ticks stay in this browser. Save them as a file on the course home.
Updated 2026-11-22. Numbers in the examples are made up to show the idea unless a source is given. Simulations run in your browser; nothing you type is sent anywhere.