Skip to content

Discrete vs continuous random variables

5 min read

Short answer

A random variable XX turns outcomes into numbers. It is discrete if it takes countable values (0, 1, 2, ...) described by a probability mass function P(X=k)P(X=k), and continuous if it takes any value in an interval, described by a probability density function f(x)f(x) whose area gives the probability. For a continuous variable, P(X=a)=0P(X=a)=0 for any single value.

Discrete compared with ContinuousDiscreteCountable valuesPMF: P(X = k)Probabilities add upΣ P(X = k) = 1Example: heads in 2flipsContinuousAny value in anintervalPDF: f(x)Probabilities = areas∫ f(x) dx = 1Example: waiting time
Count it and it is probably discrete; measure it and it is probably continuous.

Why a single point has probability zero

A continuous variable has infinitely many possible values, so each single value gets zero probability; only ranges have positive probability. f(x)f(x) is a density (probability per unit length), so it can even exceed 1 as long as the total area is 1. Because of this, P(a≤X≤b)=P(a<X<b)P(a\le X\le b)=P(a<X<b) for continuous variables.

Mean and variance in each case

The ideas are the same, with sums for discrete variables and integrals for continuous ones: E[X]=∑x P(X=x)E[X]=\sum x\,P(X=x) versus E[X]=∫xf(x) dxE[X]=\int x f(x)\,dx.

Worked example

(a) Let XX be the number of heads in two fair flips. List its distribution. (b) If YY is uniform on [0,10][0,10], find P(2≤Y≤5)P(2\le Y\le5) and P(Y=3)P(Y=3).

(a) P(X=0)=14P(X=0)=\tfrac14, P(X=1)=12P(X=1)=\tfrac12, P(X=2)=14P(X=2)=\tfrac14. These add to 1. ✓

(b) The density is f(y)=110f(y)=\tfrac1{10} on [0,10][0,10], so P(2≤Y≤5)=5−210=0.3P(2\le Y\le5)=\tfrac{5-2}{10}=0.3. And P(Y=3)=0P(Y=3)=0: a single point has no width, so no area.

Try it yourself

Is the time you wait for a bus a discrete or a continuous random variable? What about the number of buses that pass in an hour?

Show the answer

Waiting time is continuous (it can be any value in an interval, like 3.27 minutes). The number of buses is discrete (0, 1, 2, ...).

Keep going with practice

Vidi's interactive distribution plot lets you switch between discrete and continuous distributions and compare their shapes.