Table of Contents
In this chapter we focus on continuous random variables. The general ideas of random variables (such as “assigning numbers to outcomes” and the difference between discrete and continuous cases at a basic level) are assumed to be known from the parent chapter.
Here we describe what is special about the continuous case, how probabilities are represented, and how to work with them in simple situations.
What makes a variable “continuous”?
A random variable $X$ is called continuous if it can take any value in an interval (or a union of intervals) of real numbers, not just a list of isolated points.
Typical examples:
- The exact height of a person (e.g. $170.2$ cm, $170.23$ cm, etc.).
- The time it takes to run a race (e.g. $12.34$ seconds).
- The amount of rain in a day (e.g. $4.5$ mm).
The essential feature: between any two possible values of $X$, there are infinitely many other possible values, and these are all “allowed” values of the variable.
Because there are uncountably many possible values, you cannot list probabilities for each single point as in the discrete case. Instead, probabilities are described using intervals of values and a function called a probability density function.
Probability density function (pdf)
A continuous random variable $X$ is described by a probability density function (pdf), usually written $f(x)$, which satisfies two key properties:
- Nonnegativity
$$f(x) \ge 0 \quad \text{for all } x.$$ - Total probability equals 1
$$\int_{-\infty}^{\infty} f(x)\,dx = 1.$$
The probability that $X$ lies in an interval $[a,b]$ is given by the area under the curve of $f(x)$ from $a$ to $b$:
$$
P(a \le X \le b) = \int_{a}^{b} f(x)\,dx.
$$
For continuous variables, the pdf itself is not a probability; $f(x)$ can be bigger than $1$. Probability comes from integrating $f(x)$ over an interval.
Probabilities over intervals
Important facts for continuous variables:
- $P(a < X < b) = P(a \le X \le b) = P(a \le X < b) = P(a < X \le b)$
because the probability of $X$ taking any exact value is $ (we will state this precisely below).
- For any interval $[a,b]$,
$$
P(a \le X \le b) = \int_{a}^{b} f(x)\,dx.
$$
Informally, you can think of $f(x)$ as “probability per unit of $x$,” but only the area (integral) has the meaning of probability.
$P(X = a) = 0$ for continuous variables
A fundamental property of continuous random variables is:
$$
P(X = a) = 0 \quad \text{for any fixed number } a.
$$
Reason (informal): To get a positive probability, you need a nonzero width of $x$-values. A single point has “no width,” so the area under $f(x)$ at that one point is $0$.
Consequences:
- Statements like $P(X \le a)$ and $P(X < a)$ are equal.
- Likewise, $P(X \ge a)$ and $P(X > a)$ are equal.
This is a major difference from discrete random variables, where specific points can have positive probability.
Cumulative distribution function (cdf) for continuous variables
The cumulative distribution function (cdf) of a random variable $X$ is generally defined (in the parent chapter) as
$$
F(x) = P(X \le x).
$$
For a continuous random variable with pdf $f(x)$, the cdf is related to $f$ by:
$$
F(x) = \int_{-\infty}^{x} f(t)\,dt.
$$
Basic properties in the continuous case:
- $F(x)$ is nondecreasing (it never goes down as $x$ increases).
- $\lim_{x \to -\infty} F(x) = 0$ and $\lim_{x \to \infty} F(x) = 1$.
- If $f(x)$ is continuous at $x$, then $F$ is differentiable at $x$ and
$$
f(x) = \frac{d}{dx}F(x).
$$
So in the continuous case, the pdf and cdf are connected via integration and differentiation.
Using the cdf for probabilities
For any $a < b$,
$$
P(a < X \le b) = F(b) - F(a).
$$
Because single points have probability $0$, we can write this in many equivalent forms:
$$
P(a < X < b) = P(a \le X < b) = P(a \le X \le b) = F(b) - F(a).
$$
Examples of simple continuous distributions
Here we look at simple shapes of pdfs to see how calculations work. More specific named distributions (like the normal distribution) are handled in their own chapter.
Example 1: Uniform distribution on an interval
Suppose $X$ is equally likely to take any value in the interval $[0,1]$, and cannot take values outside $[0,1]$.
The pdf is
$$
f(x) =
\begin{cases}
1, & 0 \le x \le 1,\\[4pt]
0, & \text{otherwise.}
\end{cases}
$$
Check the total area:
$$
\int_{-\infty}^{\infty} f(x)\,dx = \int_{0}^{1} 1\,dx = 1,
$$
so this is a valid pdf.
Probabilities are just lengths (because the height is $1$):
- $P(0.2 \le X \le 0.5) = \int_{0.2}^{0.5}1\,dx = 0.5 - 0.2 = 0.3$.
- $P(X > 0.7) = \int_{0.7}^{1}1\,dx = 1 - 0.7 = 0.3$.
- $P(X = 0.3) = 0$ (as for any single point).
The cdf is
$$
F(x) =
\begin{cases}
0, & x < 0,\\[4pt]
x, & 0 \le x \le 1,\\[4pt]
1, & x > 1.
\end{cases}
$$
Then, for example,
$$
P(0.2 < X \le 0.5) = F(0.5) - F(0.2) = 0.5 - 0.2 = 0.3.
$$
Example 2: A triangular pdf
Let $X$ have pdf
$$
f(x) =
\begin{cases}
2x, & 0 \le x \le 1,\\[4pt]
0, & \text{otherwise.}
\end{cases}
$$
First, check that this is a valid pdf:
- Nonnegative on its support ($2x \ge 0$ for $x \ge 0$).
- Total area:
$$
\int_{-\infty}^{\infty} f(x)\,dx
= \int_{0}^{1} 2x\,dx
= \left. x^{2}\right|_{0}^{1}
= 1.
$$
To find the cdf,
$$
F(x) =
\begin{cases}
0, & x < 0,\\[4pt]
\displaystyle \int_{0}^{x} 2t\,dt = x^{2}, & 0 \le x \le 1,\\[8pt]
1, & x > 1.
\end{cases}
$$
Then
$$
P(0.5 \le X \le 0.8)
= F(0.8) - F(0.5)
= 0.8^{2} - 0.5^{2}
= 0.64 - 0.25
= 0.39.
$$
Again, $P(X = 0.5) = 0$.
Expectation and variance for continuous variables
The general ideas of mean (expectation) and variance are introduced elsewhere. For continuous random variables, they are computed using integrals instead of sums.
If $X$ is a continuous random variable with pdf $f(x)$, then:
- The expected value (or mean) of $X$ is
$$
E[X] = \int_{-\infty}^{\infty} x\,f(x)\,dx,
$$
provided this integral converges. - The variance of $X$ is
$$
\operatorname{Var}(X) = E\big[(X - E[X])^{2}\big]
= \int_{-\infty}^{\infty} (x - E[X])^{2} f(x)\,dx,
$$
again assuming the integral is finite.
An equivalent and often easier formula is
$$
\operatorname{Var}(X) = E[X^{2}] - \big(E[X]\big)^{2},
$$
where
$$
E[X^{2}] = \int_{-\infty}^{\infty} x^{2} f(x)\,dx.
$$
Example: Mean of the uniform distribution on $[0,1]$
For $X$ uniform on $[0,1]$ with pdf $f(x) = 1$ on $[0,1]$,
$$
E[X] = \int_{0}^{1} x \cdot 1\,dx
= \left. \frac{x^{2}}{2} \right|_{0}^{1}
= \frac{1}{2}.
$$
Also,
$$
E[X^{2}] = \int_{0}^{1} x^{2} \cdot 1\,dx
= \left. \frac{x^{3}}{3} \right|_{0}^{1}
= \frac{1}{3},
$$
so
$$
\operatorname{Var}(X) = E[X^{2}] - (E[X])^{2}
= \frac{1}{3} - \left(\frac{1}{2}\right)^{2}
= \frac{1}{3} - \frac{1}{4}
= \frac{1}{12}.
$$
Comparing continuous and discrete random variables
Here is a brief summary of differences that are specific to continuous variables:
- Possible values:
- Discrete: separate, countable values (e.g. $0,1,2,\dots$).
- Continuous: all real values in an interval.
- How probabilities are given:
- Discrete: a probability mass function (pmf) $P(X = x)$ for each possible value $x$.
- Continuous: a pdf $f(x)$, and probabilities are integrals: $P(a \le X \le b) = \int_{a}^{b} f(x)\,dx$.
- Point probabilities:
- Discrete: can have $P(X = x) > 0$.
- Continuous: $P(X = x) = 0$ for all $x$.
- Summation vs integration:
- Discrete: sums (e.g. $E[X] = \sum x \, P(X=x)$).
- Continuous: integrals (e.g. $E[X] = \int x \, f(x)\,dx$).
Understanding these distinctions is the key to working correctly with continuous random variables and preparing for specific continuous distributions studied later.