Probability Density Function for Continuous Random Variables

From histograms to continuous density curves — with 2 fully solved integration examples

Overview

This guide introduces the Probability Density Function (PDF) for continuous random variables. We'll start by watching discrete frequency histograms approach a smooth continuous curve as the class width shrinks toward zero, then formalize the PDF definition and its three core properties, and finally work through two fully solved integration examples (uniform and exponential distributions).

From Frequency Histograms to Probability Curves

Suppose we've recorded 2,560 time measurements (in hours) of project completion times. Since time is continuous (not restricted to integers), the underlying random variable is continuous. We start with a frequency histogram using class width 1.

Frequency histogram of 2,560 completion times, summed to 2,560
Figure 1 — Frequency histogram (total frequency = 2,560).

1. Probability histogram (class width = 1)

Convert the raw counts to probabilities by dividing each bar's height by 2,560. Now the area of each bar equals the probability that the random variable falls in that interval. The total area of all bars equals exactly 1.

Probability histogram with class width 1, where bar areas sum to 1
Figure 2 — Probability histogram (class width = 1).

2. Narrower class width (width = 0.5)

Halving the class width smooths the distribution. Notice the red trendline — it's starting to approximate the true underlying density curve.

Probability histogram with class width 0.5, showing a smoother shape and a red trendline
Figure 3 — Class width 0.5, with an approximating trendline.

3. Approaching a continuous curve (width = 0.1)

As class width approaches 0, the jagged bar edges vanish, and the histogram converges to a smooth mathematical curve. That curve is the probability density function.

Very fine probability histogram (class width 0.1) approximating a smooth continuous density curve
Figure 4 — Class width 0.1, near the continuous limit.

Key insight. In the limit, the area of each bar equals the probability of falling in that interval — which becomes \( P(a \le X \le b) = \int_a^b f_X(x)\,dx \).


Probability Density Function (PDF) Definition

For a continuous random variable \( X \) with density \( f_X(x) \), the probability that \( X \) falls in the interval \( [a, b] \) is the area under the density curve over that interval:

\[ P(a \le X \le b) = \text{Area under } f_X \text{ from } x = a \text{ to } x = b \]
Density curve with the area between a and b shaded, illustrating P(a ≤ X ≤ b)
Figure 5 — Probability as the area under a PDF.

Three Core Properties of a Valid PDF

  1. Non-negativity: \( f_X(x) \ge 0 \) for all \( x \).
  2. Unit total area: \( \displaystyle\int_{-\infty}^{\infty} f_X(x)\,dx = 1 \).
  3. Probability via integration: \( P(a \le X \le b) = \displaystyle\int_a^b f_X(x)\,dx \).

Single-point probabilities are zero. For any continuous \( X \), \( P(X = a) = \int_a^a f = 0 \). Probabilities are only positive over intervals of positive width. This implies \( P(a \le X \le b) = P(a < X < b) \).

Solved Calculus Examples

Example 1 — The Uniform Distribution

A continuous random variable \( X \) has density:

\[ f_X(x) = \begin{cases} \dfrac{c}{b-a}, & a \le x \le b \\[1em] 0, & \text{otherwise} \end{cases} \]

where \( c \) is a positive constant to be determined.

  1. Sketch \( f_X(x) \).
  2. Find the value of \( c \) that makes \( f_X \) a valid PDF.
  3. Verify the total area equals 1 by integration.
  4. With \( a = 3 \) and \( b = 8 \), compute \( P(4 \le X \le 7) \).
View solution

(a) Sketch. The function is constant \( \dfrac{c}{b-a} \) on \( [a, b] \) and 0 elsewhere — a rectangle of height \( \dfrac{c}{b-a} \) and width \( b - a \).

Rectangular uniform PDF of height c/(b−a) between x = a and x = b
Figure 6 — Uniform density as a rectangle.

(b) Determine \( c \). Total area = width × height:

\[ \text{Area} = (b-a) \cdot \frac{c}{b-a} = c \]

Setting the total area to 1 gives \( c = 1 \). So the valid PDF is:

\[ f_X(x) = \begin{cases} \dfrac{1}{b-a}, & a \le x \le b \\ 0, & \text{otherwise} \end{cases} \]

(c) Verify by integration.

\[ \int_{-\infty}^{\infty} f_X(x)\,dx = \int_a^b \frac{1}{b-a}\,dx = \left[\frac{x}{b-a}\right]_a^b = \frac{b-a}{b-a} = 1 \]

(d) Probability on [4, 7] with \( a = 3, b = 8 \). The height is \( \dfrac{1}{5} \):

\[ P(4 \le X \le 7) = \int_4^7 \frac{1}{5}\,dx = \left[\frac{x}{5}\right]_4^7 = \frac{7-4}{5} = \frac{3}{5} = 0.6 \]

Example 2 — The Exponential Distribution

A continuous random variable \( X \) has density:

\[ f_X(x) = \begin{cases} k\, e^{-kx}, & x \ge 0 \\ 0, & x < 0 \end{cases} \]

where \( k > 0 \) is the rate parameter.

  1. Verify that \( f_X \) is a valid PDF for any \( k > 0 \).
  2. For \( k = 1 \), find the value \( a \) such that \( P(0 \le X \le a) = 0.9 \).

Form note. The standard exponential PDF is \( f(x) = \lambda e^{-\lambda x} \) for \( x \ge 0 \), with \( \lambda \) as the rate. Here we use \( k \) in place of \( \lambda \) to emphasize that the leading coefficient and the exponent must match for the total area to equal 1.

View solution

(a) Verify it's a PDF. Since the density is 0 for \( x < 0 \), integrate from 0 to ∞:

\[ \int_{-\infty}^{\infty} f_X(x)\,dx = \int_0^{\infty} k e^{-kx}\,dx = \lim_{b \to \infty} \left[-e^{-kx}\right]_0^b = \lim_{b \to \infty} \left(1 - e^{-kb}\right) = 1 \]

The last step uses \( k > 0 \), so \( e^{-kb} \to 0 \) as \( b \to \infty \). ✓

(b) Find \( a \) such that \( P(0 \le X \le a) = 0.9 \) when \( k = 1 \). With \( k = 1 \), the density is \( e^{-x} \):

\[ P(0 \le X \le a) = \int_0^a e^{-x}\,dx = \left[-e^{-x}\right]_0^a = 1 - e^{-a} \]

Set equal to 0.9:

\[ 1 - e^{-a} = 0.9 \;\Rightarrow\; e^{-a} = 0.1 \;\Rightarrow\; a = -\ln(0.1) \approx 2.3026 \]

Answer: \( a \approx 2.3026 \).


Practice Problems

Practice 1 — Verify a PDF

Determine whether \( f(x) = 2x \) for \( 0 \le x \le 1 \) (and 0 otherwise) is a valid PDF.

Answer

Non-negativity: \( 2x \ge 0 \) on \( [0,1] \) ✓.

Total area:

\[ \int_0^1 2x\,dx = \left[x^2\right]_0^1 = 1 \; \checkmark \]

So \( f \) is a valid PDF.

Practice 2 — Probability from a PDF

Let \( f(x) = 2x \) on \( [0, 1] \) and 0 otherwise. Compute \( P(0.25 \le X \le 0.75) \).

Answer
\[ P(0.25 \le X \le 0.75) = \int_{0.25}^{0.75} 2x\,dx = \left[x^2\right]_{0.25}^{0.75} = 0.5625 - 0.0625 = 0.5 \]

Practice 3 — Normalizing constant

A continuous random variable \( X \) has density \( f(x) = c(1 - x^2) \) for \( -1 \le x \le 1 \) and 0 otherwise. Find the constant \( c \).

Answer

Total area = 1:

\[ \int_{-1}^{1} c(1 - x^2)\,dx = c\left[x - \frac{x^3}{3}\right]_{-1}^{1} = c\left[\frac{2}{3} - \left(-\frac{2}{3}\right)\right] = \frac{4c}{3} \] \[ \frac{4c}{3} = 1 \;\Rightarrow\; c = \frac{3}{4} \]

Frequently Asked Questions

What is a probability density function (PDF)?

For a continuous random variable \(X\), the PDF \(f_X(x)\) describes how probability is distributed. The probability that \(X\) falls in an interval \([a, b]\) is the area under the density curve over that interval: \(P(a \le X \le b) = \int_a^b f_X(x)\,dx\).

What are the three properties of a PDF?

(1) Non-negativity: \(f_X(x) \ge 0\) for all \(x\). (2) Unit total area: \(\int_{-\infty}^{\infty} f_X(x)\,dx = 1\). (3) Probability = area: \(P(a \le X \le b) = \int_a^b f_X(x)\,dx\).

Why is the probability of a single point zero for a continuous random variable?

Because \(P(X = a) = \int_a^a f_X(x)\,dx = 0\) — the integral over an interval of zero width is zero. Probabilities are only positive over intervals of positive length, which is why \(P(a \le X \le b) = P(a < X < b)\) for continuous variables.

What is the relationship between the PDF and the CDF?

The CDF \(F(x) = P(X \le x) = \int_{-\infty}^x f_X(t)\,dt\) is the integral of the PDF. Conversely, \(f_X(x) = F'(x)\) wherever \(F\) is differentiable. The PDF is the "rate" at which the CDF accumulates probability.

Related Calculus & Probability Resources

Last updated: October 20, 2026