Guides / Probability

Continuous random variables: probability is area under the density, and the CDF does the integrating

A continuous random variable can take any value in a range: a waiting time, a measurement, a weight in a neural network. No single value has positive probability, so the distribution is described by a density f(x), and probabilities are areas under it. The mistakes come from reading the height of the density as a probability, from mixing up a rate with a mean, and from dividing by the variance where the standard deviation belongs.

Short answer

A density has f(x) ≥ 0 and total area ∫ f(x) dx = 1. Then P(a < X < b) = ∫ab f(x) dx = F(b) − F(a), where the CDF F(x) = P(X ≤ x) and F′ = f. The mean and variance are integrals: E[X] = ∫ x f(x) dx and Var(X) = E[X2] − (E[X])2. The three to know: uniform on [a, b] with mean (a + b)/2 and variance (b − a)2/12; exponential with rate λ, P(X > x) = e−λx and mean 1/λ; normal N(μ, σ2), standardized by z = (x − μ)/σ.

Why it works

Think of a histogram of many results with narrower and narrower bars. If each bar's area is the fraction of results that land in it, the tops of the bars settle onto a curve, and that curve is the density. A probability is then an area under the curve, and the probability of hitting one exact value is the area of a line, which is 0. That's why P(X < b) and P(X ≤ b) are the same for a continuous variable.

The height f(x) is probability per unit of x: P(x < X < x + dx) ≈ f(x) dx. It can be bigger than 1 when the values are packed into a short interval. The CDF collects the area to the left of x, so it climbs from 0 to 1, and differentiating it gives the density back, which is just the fundamental theorem of calculus.

Example 1: normalize a density, then find a probability

f(x) = cx2 for 0 ≤ x ≤ 3, and 0 elsewhere. Find c, the CDF and P(1 < X < 2).

  1. ∫03 cx2 dx = 9c = 1 ⇒ c = 19The total area must be 1: c · 27/3 = 9c.
  2. F(x) = ∫0x t29 dt = x327 for 0 ≤ x ≤ 3F is 0 to the left of 0 and 1 to the right of 3. Check: F(3) = 1.
  3. P(1 < X < 2) = F(2) − F(1) = 8 − 127 = 727 ≈ 0.259The CDF has done the integrating, so a probability is a subtraction.

Example 2: the mean and variance by integration

Find E[X], Var(X) and the standard deviation for the density in Example 1.

  1. E[X] = ∫03 x · x29 dx = 19 · 814 = 94 = 2.25The sum Σ x P(X = x) becomes an integral of x times the density.
  2. E[X2] = ∫03 x2 · x29 dx = 19 · 2435 = 5.4Square x, keep the same density.
  3. Var(X) = 5.4 − 2.252 = 2780 = 0.3375, SD ≈ 0.581The same shortcut as for a discrete variable. The mean sits right of the middle of [0, 3] because the density grows toward 3.

Example 3: an exponential waiting time

Support tickets arrive at a rate of 0.5 per hour, so the wait X for the next one is exponential with λ = 0.5. Find the mean wait, P(X > 3), the median, and P(X > 5 | X > 2).

  1. E[X] = 1λ = 2 hoursA rate of 0.5 per hour means one every 2 hours on average.
  2. P(X > 3) = e−0.5 · 3 = e−1.5 ≈ 0.2231The exponential's survival function is P(X > x) = e−λx, so F(x) = 1 − e−λx.
  3. e−0.5m = ½ ⇒ m = ln 20.5 ≈ 1.386 hoursThe median is where F reaches ½. It's less than the mean: a few long waits pull the mean up.
  4. P(X > 5 | X > 2) = e−2.5e−1 = e−1.5 ≈ 0.2231The same as P(X > 3). The exponential is memoryless: having waited 2 hours, the remaining wait has the same distribution as a fresh one.

Example 4: a normal probability by standardizing

Scores are normal with mean 100 and standard deviation 15. Find P(X > 130) and P(85 < X < 115).

  1. z = 130 − 10015 = 2Subtract the mean and divide by the standard deviation: z counts standard deviations from the mean, and Z = (X − μ)/σ is standard normal.
  2. P(X > 130) = 1 − Φ(2) ≈ 1 − 0.9772 = 0.0228Φ is the standard normal CDF, from a table or a calculator.
  3. P(85 < X < 115) = Φ(1) − Φ(−1) ≈ 0.682785 and 115 are one standard deviation either side of the mean: the 68% of the 68–95–99.7 rule.

Common mistakes, and the exact line they happen on

1. Reading the density as a probability

X is uniform on [0, 0.5].

  1. f(x) = 10.5 = 2 on [0, 0.5]Right so far: the height times the width 0.5 must be 1.
  2. P(X = 0.25) = f(0.25) = 2This is the mistake. No probability can be 2. The density is probability per unit length, so it only becomes a probability when multiplied by a width: P(X = 0.25) = 0, and P(0.2 < X < 0.3) = 2 · 0.1 = 0.2.

2. Using the mean where the rate belongs

The tickets from Example 3, with a mean wait of 2 hours.

  1. P(X > x) = e−λxRight so far.
  2. λ = 2, so P(X > 3) = e−6 ≈ 0.0025This is the mistake. λ is the rate, 0.5 per hour, and the mean is 1/λ. Using the mean as the rate makes long waits look almost impossible. The right answer is e−1.5 ≈ 0.2231. Check the units: λx has to be a plain number, so λ is per hour when x is in hours.

3. Dividing by the variance when standardizing

The scores from Example 4, written as N(100, 225).

  1. μ = 100, σ2 = 225Right so far: N(μ, σ²) lists the variance.
  2. z = 130 − 100225 ≈ 0.133, P(X > 130) ≈ 0.447This is the mistake. z is measured in standard deviations, so divide by σ = √225 = 15. Then z = 2 and P(X > 130) ≈ 0.0228. A score two standard deviations up should be rare, and 45% isn't.

Practice

  1. f(x) = c(1 − x2) on [−1, 1]. Find c and P(X > ½).

    Show answer

    ∫−11 (1 − x2) dx = 43, so c = 34, and P(X > ½) = 34∫½1 (1 − x2) dx = 532 ≈ 0.156.

  2. X is uniform on [2, 8]. Find its mean, its variance and P(X < 3.5).

    Show answer

    Mean 5, variance 62/12 = 3, and P(X < 3.5) = 1.5/6 = 0.25.

  3. A wait is exponential with mean 10 minutes. What is the probability it is under 5 minutes?

    Show answer

    The rate is λ = 0.1 per minute, so P(X < 5) = 1 − e−0.5 ≈ 0.3935.

  4. X is normal with mean 50 and standard deviation 4. Find P(X < 44).

    Show answer

    z = (44 − 50)/4 = −1.5, and Φ(−1.5) ≈ 0.0668.

  5. X has CDF F(x) = 1 − 1/x2 for x ≥ 1. Find its density, its median and its mean.

    Show answer

    f(x) = F′(x) = 2/x3. The median solves 1/x2 = ½, so it is √2 ≈ 1.414. The mean is ∫1∞ x · 2/x3 dx = 2.