Skip to content
Educora
University32 min80 / 82

Random variables and distributions

Discrete and continuous random variables, expectation and variance, the binomial, Poisson, uniform and normal distributions, the 68–95–99.7 rule and z-scores, the law of large numbers and the central limit theorem.

Check yourself
In this lesson you will learn
  • Describe a discrete random variable by its distribution and a continuous one by its density
  • Compute the expectation, the variance and the standard deviation
  • Apply the binomial, Poisson, uniform and normal distributions to typical problems
  • Explain the law of large numbers and the central limit theorem, and use z-scores

A bank's call centre in Bakı receives on average 3 calls a minute. How likely is a minute with no calls at all, and how many operators are needed? How many students in a class of 30 will score above 90 points? Such questions are about random variables: numbers whose value depends on chance. Knowing their distribution lets us compute probabilities, averages and risks before the random experiment even happens.

Discrete and continuous random variables

Definition
Random variable

A quantity X that takes a numerical value depending on the outcome of a random experiment. It is discrete if its values can be listed (number of heads, calls per minute) and continuous if it can take any value in an interval (height, waiting time).

A discrete random variable is given by its distribution law: the values xᵢ with their probabilities pᵢ = P(X = xᵢ), where all the pᵢ add up to 1. For example, let X be the number of heads in three tosses of a coin. Of the 8 equally likely outcomes, 1 gives 0 heads, 3 give 1 head, 3 give 2 heads and 1 gives 3 heads:

xᵢ0123
pᵢ1/83/83/81/8
Distribution of the number of heads in three tosses: 1/8 + 3/8 + 3/8 + 1/8 = 1.

A continuous random variable has a probability density f(x) ≥ 0: probabilities are areas under its graph. The total area is 1, and the probability of one exact value is 0: P(X = 175 cm) = 0, and only intervals have positive probability.

P(a ≤ X ≤ b) = ∫ₐᵇ f(x) dx
where:
  • f(x)the probability density
  • a, bthe ends of the interval

The integral of f over the whole number line equals 1.

Expectation and variance

E(X) = ∑ xᵢ · pᵢ, E(X) = ∫ x · f(x) dx
where:
  • E(X) = μthe expectation (mean value)
  • xᵢ, pᵢvalues and probabilities of a discrete variable
  • f(x)the density of a continuous variable

The first formula is for discrete variables, the second for continuous ones. The expectation is the balance point of the distribution: the long-run average of many repetitions.

Var(X) = E[(X − μ)²] = E(X²) − μ², σ = √Var(X)
where:
  • Var(X)the variance: the mean squared deviation from the mean
  • σthe standard deviation (in the same units as X)

The second form comes from expanding the square: E[(X − μ)²] = E(X²) − 2μ·E(X) + μ² = E(X²) − μ².

E(aX + b) = a·E(X) + b, Var(aX + b) = a²·Var(X)
where:
  • a, bconstants

Always E(X + Y) = E(X) + E(Y); and Var(X + Y) = Var(X) + Var(Y) when X and Y are independent.

Three coins

X is the number of heads in three tosses (table above). Find E(X), Var(X) and σ.

Show solution
E(X) = 0·1/8 + 1·3/8 + 2·3/8 + 3·1/8 = 12/8 = 1.5.
E(X²) = 0·1/8 + 1·3/8 + 4·3/8 + 9·1/8 = 24/8 = 3.
Var(X) = 3 − 1.5² = 3 − 2.25 = 0.75, σ = √0.75 ≈ 0.87.
On average 1.5 heads, a value X itself never takes: an expectation need not be a possible value.
Is the game worth it?

At a fair you pay 2 manat and roll a die. A six wins 10 manat; otherwise you get nothing. What is your expected profit?

Show solution
Profit X: 10 − 2 = 8 manat with probability 1/6, and −2 manat with probability 5/6.
E(X) = 8·1/6 + (−2)·5/6 = 8/6 − 10/6 = −2/6 ≈ −0.33 manat.
On average you lose a third of a manat per game; over 300 games that is about 100 manat, which is the organiser's profit.

Discrete distributions: binomial and Poisson

P(X = k) = C(n, k) · pᵏ · (1 − p)ⁿ⁻ᵏ, E(X) = np, Var(X) = np(1 − p)
where:
  • nthe number of independent trials
  • pthe probability of success in one trial
  • kthe number of successes, 0 ≤ k ≤ n
  • C(n, k)the binomial coefficient n! / (k!(n − k)!)

The binomial distribution B(n, p): the number of successes in n independent trials with the same p.

Guessing on a test

A test has 5 questions with 4 options each. Murad picks every answer at random. Find the probability of exactly 3 correct answers and the expected number of correct answers.

Show solution
n = 5, p = 1/4, k = 3.
C(5, 3) = 10, so P(X = 3) = 10 · (1/4)³ · (3/4)² = 10 · 1/64 · 9/16 = 90/1024 ≈ 0.088.
E(X) = np = 5 · 0.25 = 1.25, Var(X) = 5 · 0.25 · 0.75 ≈ 0.94.
The chance of 3 or more correct answers is only about 0.10: guessing is a poor strategy.
Interactive
Loading simulation…
Probabilities of k correct answers when Murad guesses. The most likely result is 1 correct answer (≈ 0.396); 3 or more correct answers have a probability of only ≈ 0.104. All the columns add up to 1.
P(X = k) = λᵏ · e^(−λ) / k!, E(X) = Var(X) = λP(X = k) = λᵏ · e^(−λ) / k!, E(X) = Var(X) = λ
where:
  • λthe average number of events per unit of time (or space)
  • kthe values 0, 1, 2, …

The Poisson distribution: the number of rare, independent events in a fixed time or area (calls, website visits, typing errors, radioactive decays).

The call centre

A call centre receives on average 3 calls a minute (Poisson, λ = 3). Find the probability of a) no calls in a minute; b) exactly 3 calls; c) more than 2 calls.

Show solution
a) P(0) = e^(−3) ≈ 0.050.
b) P(3) = 3³ · e^(−3) / 3! = 4.5 · e^(−3) ≈ 0.224.
c) P(X > 2) = 1 − [P(0) + P(1) + P(2)] = 1 − e^(−3)(1 + 3 + 4.5) = 1 − 8.5e^(−3) ≈ 0.577.
In c) the complement saves us from adding infinitely many terms.
Interactive
Loading simulation…
The probability of k calls in one minute. The most likely values are 2 and 3 (≈ 0.224 each). The first three columns (0, 1, 2 calls) add up to ≈ 0.423, so P(X > 2) ≈ 0.577. To the right the columns shrink fast but never become exactly zero.

Continuous distributions: uniform and normal

f(x) = 1/(b − a), a ≤ x ≤ b; E(X) = (a + b)/2, Var(X) = (b − a)²/12f(x) = 1/(b − a), a ≤ x ≤ b; E(X) = (a + b)/2, Var(X) = (b − a)²/12
where:
  • a, bthe ends of the interval (outside it f(x) = 0)

The uniform distribution: all parts of [a, b] of the same length are equally likely. Example: a bus comes every 10 minutes and you arrive at a random moment. The wait is uniform on [0, 10], 5 minutes on average, and P(wait > 7 min) = 3/10.

f(x) = 1 / (σ√(2π)) · e^(−(x − μ)² / (2σ²))f(x) = 1 / (σ√(2π)) · e^(−(x − μ)² / (2σ²))
where:
  • μthe mean: the centre of the bell
  • σthe standard deviation: the width of the bell

The normal (Gaussian) distribution N(μ, σ²): a symmetric bell-shaped curve.

Interactive
Loading simulation…
The density of N(μ, σ²) with μ = m and σ = s. Changing m shifts the bell; a larger s makes it lower and wider, because the area under it always stays 1.
P(|X − μ| ≤ σ) ≈ 0.68, P(|X − μ| ≤ 2σ) ≈ 0.95, P(|X − μ| ≤ 3σ) ≈ 0.997
where:
  • μ, σthe mean and standard deviation of the normal distribution

The 68–95–99.7 rule (three-sigma rule): almost all values lie within 3σ of the mean.

z = (x − μ) / σz = (x − μ) / σ
where:
  • zthe z-score: how many standard deviations x lies from the mean
  • Φ(z)the standard normal distribution function: P(Z ≤ z), Z ~ N(0, 1)

Any normal X can be standardised: P(X ≤ x) = Φ((x − μ)/σ). By symmetry, Φ(−z) = 1 − Φ(z).

zΦ(z) = P(Z ≤ z)
00.5000
0.50.6915
10.8413
1.50.9332
20.9772
2.50.9938
30.9987
Some values of the standard normal distribution function.
Heights and z-scores

Suppose the heights of young men are approximately N(175, 7²) cm. What share of them is a) taller than 189 cm; b) between 168 and 182 cm; c) shorter than 164.5 cm?

Show solution
a) z = (189 − 175)/7 = 2; P(X > 189) = 1 − Φ(2) = 1 − 0.9772 ≈ 2.3% (the rule of thumb gives about 2.5%).
b) 168 and 182 are μ ± σ, so the share is about 68%.
c) z = (164.5 − 175)/7 = −1.5; P = Φ(−1.5) = 1 − Φ(1.5) = 1 − 0.9332 ≈ 6.7%.

The law of large numbers and the central limit theorem

The law of large numbers says that the average of many independent repetitions settles down to the expectation. That is why a casino, an insurance company or a bank can plan with averages, even though every single game or client is random.

X̄ₙ = (X₁ + X₂ + … + Xₙ) / n → μ (n → ∞)X̄ₙ = (X₁ + X₂ + … + Xₙ) / n → μ (n → ∞)
where:
  • X₁, …, Xₙindependent repetitions with mean μ
  • X̄ₙthe sample mean of n values
Interactive
Loading simulation…
Toss the coin many times: the share of heads approaches 0.5. This is the law of large numbers at work.

The central limit theorem goes further: the sum or average of many independent random variables is approximately normal, whatever their own distribution. This is why heights, measurement errors and exam totals, which add up many small effects, follow the bell curve. The spread of the average shrinks like σ/√n (the standard error of the mean).

X̄ₙ ≈ N(μ, σ²/n), (X̄ₙ − μ) / (σ/√n) ≈ N(0, 1)X̄ₙ ≈ N(μ, σ²/n), (X̄ₙ − μ) / (σ/√n) ≈ N(0, 1)
where:
  • σ/√nσ/√nthe standard error of the mean
  • nthe number of observations (in practice n ≥ 30 is usually enough)
One hundred dice

100 dice are rolled. Estimate the probability that the total S is between 316 and 384.

Show solution
One die: μ = 3.5, σ² = [(1 − 3.5)² + … + (6 − 3.5)²]/6 = 35/12 ≈ 2.92.
For the total: E(S) = 100 · 3.5 = 350, Var(S) = 100 · 35/12 ≈ 291.7, σ(S) ≈ 17.1.
By the central limit theorem S is roughly normal, and 316 … 384 is 350 ± 34 ≈ μ ± 2σ. The probability is about 95%.
An exact computer calculation gives 95.7%, very close.

Key points

  • A discrete X is given by a table (probabilities sum to 1), a continuous X by a density: probability is area and P(X = a) = 0.
  • E(X) = ∑xᵢpᵢ; Var(X) = E(X²) − (E X)²; σ = √Var(X).
  • E(aX + b) = a·E(X) + b and Var(aX + b) = a²·Var(X).
  • Binomial: E = np, Var = np(1 − p); Poisson: E = Var = λ; uniform on [a, b]: E = (a + b)/2.
  • Normal distribution: the 68–95–99.7 rule; z = (x − μ)/σ turns any normal variable into N(0, 1).
  • Law of large numbers: averages → μ; central limit theorem: averages ≈ N(μ, σ²/n), and the error falls like 1/√n.

Check yourself

10 questions. Every correct answer earns XP.

1 / 10
X takes the values 1, 2, 3 with probabilities 0.2, 0.5, 0.3. What is Var(X)?