Track 5 · Probability Distributions · Lesson 1 of 10

Random variables and their distributions

Describe a random variable with its pmf or pdf and cdf, and calculate its mean, variance and standard deviation.

30 minIntermediate8 graded exercisesFree

An insurer cannot know how many claims a particular policy will produce next year, but it must still price the policy. Treating the claim count as a random variable with a distribution turns that uncertainty into numbers the insurer can plan with: the probability of no claim, the expected number of claims, and how much that number varies.

A random variable is a numerical outcome of a random process: the number of claims on a policy, the number of heads in ten tosses, the time until the next call arrives. We write it with a capital letter, XX, and a particular value it can take with a small letter, xx.

The distribution of XX lists which values are possible and how probable they are. Every model in this track — binomial, Poisson, normal, t and the rest — is a distribution with a name and a few parameters.

DiscreteContinuous
ValuesSeparate, countable values (0, 1, 2, …)Any value in an interval
Typical sourceCountingMeasuring (time, weight, distance)
Described byProbability mass function (pmf)Probability density function (pdf)
Probability of one exact valueCan be positiveAlways 0
ExamplesClaims per policy, defective items in a batchWaiting time, finish time of a race
Two kinds of random variable
p(x)=P(X=x),∑xp(x)=1,F(x)=P(X≤x)p(x) = P(X = x), \qquad \sum_{x} p(x) = 1, \qquad F(x) = P(X \le x)
Probability mass function and cumulative distribution function of a discrete random variable
p(x)p(x)
the probability that XX takes exactly the value xx; each p(x)p(x) is between 0 and 1
∑xp(x)=1\sum_x p(x) = 1
the probabilities of all possible values add up to 1
F(x)F(x)
the cumulative distribution function (cdf): the probability that XX is at most xx. Convention: P(X≤x)P(X \le x) includes xx itself

For a discrete variable the cdf is a staircase: it jumps by p(x)p(x) at each possible value and is flat in between. Because the jump at kk belongs to P(X≤k)P(X \le k), the two neighbouring questions have different answers:

P(X<k)=P(X≤k−1),P(X≥k)=1−P(X≤k−1).P(X < k) = P(X \le k-1), \qquad P(X \ge k) = 1 - P(X \le k-1).

Getting << versus ≤\le right is the most common source of wrong answers with discrete distributions.

μ=E⁡[X]=∑xx p(x),σ2=Var⁡(X)=∑x(x−μ)2p(x)=E⁡[X2]−μ2,σ=σ2\mu = \E[X] = \sum_x x\,p(x), \qquad \sigma^2 = \Var(X) = \sum_x (x-\mu)^2 p(x) = \E[X^2] - \mu^2, \qquad \sigma = \sqrt{\sigma^2}
Mean (expected value), variance and standard deviation of a discrete random variable
μ=E⁡[X]\mu = \E[X]
the expected value: the probability-weighted average of the possible values, i.e. the long-run average over many repetitions
σ2\sigma^2
the variance: the probability-weighted average squared distance from μ\mu (in squared units)
E⁡[X2]\E[X^2]
∑xx2p(x)\sum_x x^2 p(x), the expected value of the square of XX
σ\sigma
the standard deviation: the square root of the variance, in the same units as XX

Worked example

Complaints per day

A shop's number of customer complaints in a day, XX, has this distribution: P(X=0)=0.5P(X=0) = 0.5, P(X=1)=0.3P(X=1) = 0.3, P(X=2)=0.15P(X=2) = 0.15, P(X=3)=0.05P(X=3) = 0.05. Find P(X≤1)P(X \le 1), P(X<1)P(X < 1), the mean, the variance and the standard deviation.

  1. Check it is a distribution. Every probability is between 0 and 1 and they sum to 1.00.

  2. Cumulative probabilities. P(X≤1)=0.5+0.3=0.80P(X \le 1) = 0.5 + 0.3 = 0.80, but P(X<1)=P(X=0)=0.5P(X < 1) = P(X = 0) = 0.5 — the value 1 itself is excluded.

  3. Mean. μ=0(0.5)+1(0.3)+2(0.15)+3(0.05)=0.75\mu = 0(0.5) + 1(0.3) + 2(0.15) + 3(0.05) = 0.75 complaints per day.

  4. Variance. E⁡[X2]=0(0.5)+1(0.3)+4(0.15)+9(0.05)=1.35\E[X^2] = 0(0.5) + 1(0.3) + 4(0.15) + 9(0.05) = 1.35, so σ2=1.35−0.752=0.7875\sigma^2 = 1.35 - 0.75^2 = 0.7875 complaints².

  5. Standard deviation. σ=0.7875=0.8874\sigma = \sqrt{0.7875} = 0.8874 complaints.

P(X≤1)=0.80P(X \le 1) = 0.80, P(X<1)=0.5P(X < 1) = 0.5, μ=0.75\mu = 0.75, σ2=0.7875\sigma^2 = 0.7875, σ≈0.89\sigma ≈ 0.89. Over many days the shop averages 0.75 complaints a day, even though no single day can have exactly 0.75 complaints.

A continuous random variable, such as a waiting time, can take any value in an interval. It is described by a probability density function f(x)f(x): a curve that is never negative and has total area 1 underneath it. Probabilities are areas under the curve:

P(a≤X≤b)=∫abf(x) dx.P(a \le X \le b) = \int_a^b f(x)\,dx.

A single point has no width, so it has no area: for continuous XX, P(X=x)=0P(X = x) = 0 for every xx. That is why P(X≤b)P(X \le b) and P(X<b)P(X < b) are equal for continuous variables, unlike discrete ones. The mean and variance are defined as for discrete variables with the sum replaced by an integral.

Bar chart of a binomial distribution with n = 10 and p = 0.3: bars at 0 to 10, highest at 3, with bars 0 to 3 shaded.x (successes in 10 trials)Probability
A discrete distribution: probability bars at 0, 1, …, 10. The shaded bars make up $P(X \le 3) = 0.6496$ — the bar at 3 is included.
Show the data as a table
x (successes in 10 trials)P(X = x)
00.0282475
10.121061
20.233474
30.266828
40.200121
50.102919
60.0367569
70.00900169
80.0014467
90.000137781
100.0000059049
Loading the interactive…
Explore a discrete distribution, then a continuous one. The explorer shades the probability you ask for and reports the mean and variance.

Try this

  • With the binomial distribution shown, compare P(X≤3)P(X \le 3) with P(X≤2)P(X \le 2). The difference is exactly the height of the bar at 3.

  • Switch the family to normal. Shade P(X≤a)P(X \le a) and then move aa slowly: the probability changes smoothly, with no jumps, because no single value carries any probability.

  • For the normal family, compare the variance and the standard deviation reported. Which one has the same units as XX?

Quick check

The time TT a customer spends on hold is continuous. Which statement is true?

Dataset

Motor insurance claims

1,500 rows · one row = one motor policy (one policy year) · synthetic data

PolicyDriver age bandExposure (years)Claims (claims)
POL000136-5010
POL000251-6510
POL000326-3510
POL000426-350.940
POL000526-3512
POL000651-650.980

One row per motor policy in a (synthetic) insurer's portfolio. claim_count is a discrete random variable observed 1 500 times.

Exercises

The lesson is complete when every exercise is answered correctly. Hints are free; viewing a worked solution before solving means the exercise won't count towards mastery.

0 of 8 exercises correct (not saved — sign in to keep your progress)

Exercise 1 · Practice, difficulty 1 of 3

Discrete or continuous?

Not started

Classify each random variable as discrete or continuous.

Number of claims a motor policy makes in a year
Time until the next call arrives at a contact centre
Number of defective panels in a batch of 500
Finish time of a 10 km runner
Number of heads in 20 coin tosses
Weight of a bag of rice labelled 5 kg

Exercise 2 · Guided, difficulty 1 of 3

Expected number of items

Not started

XX is the number of items a visitor to an online shop puts in the basket. Its distribution is

xx01234
P(X=x)P(X = x)0.300.250.050.200.20

Find the expected value E⁡[X]\E[X]. Give your answer to 2 decimal places.

Exercise 3 · Practice, difficulty 2 of 3

Variance and standard deviation

Not started

The number of support tickets XX a technician closes in an hour has this distribution:

xx01234
P(X=x)P(X = x)0.250.200.200.200.15

The mean is μ=1.80\mu = 1.80. Find the variance and the standard deviation of XX, each to 4 decimal places.

Exercise 4 · Practice, difficulty 2 of 3

Reading the cdf: ≤ versus <

Not started

XX is the number of parcels a courier fails to deliver on a shift:

xx012345
P(X=x)P(X = x)0.150.100.250.200.150.15

Find P(X≤2)P(X \le 2) and P(X<2)P(X < 2). Give both to 2 decimal places.

Exercise 5 · Practice, difficulty 2 of 3

The missing probability

Not started

A game awards XX points per round with the distribution below, but one probability is missing.

xx01234
P(X=x)P(X = x)?0.150.150.300.30

Find the missing probability P(X=0)P(X = 0), and then P(X≥2)P(X \ge 2). Give both to 2 decimal places.

Exercise 6 · Challenge, difficulty 3 of 3

Probability as area under a density

Not started

The time TT (minutes) a printing job waits in a queue has density f(t)=t/50f(t) = t/50 for 0≤t≤100 \le t \le 10 (and 0 elsewhere): a triangle with total area 1.

Find P(2<T≤9)P(2 < T \le 9) to 4 decimal places. (Hint: the area under ff from 0 to tt is t2/100t^2/100.)

Exercise 7 · Application, difficulty 2 of 3

The empirical distribution of claim counts

Not started

Treat claim_count in the insurance_claims dataset (1 500 policies) as observations of a random variable XX. Using the relative frequencies as probabilities, find the mean number of claims per policy (3 decimal places) and the proportion of policies with at least one claim, P(X≥1)P(X \ge 1) (4 decimal places).

Data: insurance_claims · Open in the lab to explore and calculate.

Exercise 8 · Interpretation, difficulty 2 of 3

What an expected value means

Not started

A raffle ticket's net gain XX (in SAR) has expected value E⁡[X]=−2.5\E[X] = -2.5 and standard deviation σ=40\sigma = 40. Which statement is correct?

Choose one

What you can now do

  • Classify a random variable as discrete or continuous
  • Read probabilities from a pmf and a cdf, distinguishing P(X ≤ k) from P(X < k)
  • Explain why P(X = x) = 0 for a continuous variable and find probabilities as areas
  • Calculate the mean, variance and standard deviation of a discrete random variable and interpret the mean as a long-run average