Expected Value of a Continuous Random Variable
The expected value of a continuous random variable X with density f is E(X) = \int_{-\infty}^{\infty} x f(x)\,dx, the balance point of the density. Its variance is \operatorname{Var}(X) = E(X^2) - [E(X)]^2, where E(X^2) = \int x^2 f(x)\,dx. The standard deviation is the square root of the variance.
Before this lesson: Expected Value, Probability Density Functions and Cumulative Distribution Functions
From a sum to an integral
For a discrete variable, the expected value is a weighted average: multiply each value by its probability and add, E(X) = Σ x·P(X = x). A continuous variable has a density instead of point probabilities. A thin slice near x has probability about f(x)Δx, so the sum becomes an integral of x times f(x).
Picture the region under the density cut out of thin metal. The mean is the point where it would balance on a fulcrum. Values far from the center pull hard on that balance point, so a long tail drags the mean toward it.
Expected value and variance formulas
For a continuous random variable X with density f,
E(X) = \int_{-\infty}^{\infty} x f(x)\,dx, \qquad E\big(g(X)\big) = \int_{-\infty}^{\infty} g(x) f(x)\,dxThe second formula finds the mean of any function of X without finding the density of g(X) first. Writing μ = E(X), the variance and standard deviation are
\operatorname{Var}(X) = E\big[(X - \mu)^2\big] = E(X^2) - \mu^2, \qquad \sigma = \sqrt{\operatorname{Var}(X)}For constants a and b, E(aX + b) = aE(X) + b and Var(aX + b) = a²Var(X), the same rules as for discrete variables.
Steps
- Multiply x by the density and integrate over the interval where f is not 0. This gives μ = E(X).
- Multiply x² by the density and integrate. This gives E(X²).
- Subtract: Var(X) = E(X²) − μ².
- Take the square root for the standard deviation.
Expected value of a continuous random variable examples
Example 1: Mean, variance and standard deviation
X has density f(x) = x²/9 for 0 ≤ x ≤ 3, and 0 elsewhere. Find E(X), Var(X) and the standard deviation.
E(X) = \int_0^3 x \cdot \dfrac{x^2}{9}\,dx = \int_0^3 \dfrac{x^3}{9}\,dxMultiply x by the density.
E(X) = \left[\dfrac{x^4}{36}\right]_0^3 = \dfrac{81}{36} = \dfrac{9}{4}Integrate with the power rule (see antiderivatives) and evaluate.
E(X^2) = \int_0^3 x^2 \cdot \dfrac{x^2}{9}\,dx = \left[\dfrac{x^5}{45}\right]_0^3Multiply x² by the density and integrate.
E(X^2) = \dfrac{243}{45} = \dfrac{27}{5} = 5.4Evaluate and simplify.
\operatorname{Var}(X) = 5.4 - (2.25)^2 = 5.4 - 5.0625Subtract the square of the mean.
\operatorname{Var}(X) = 0.3375Subtract.
\sigma = \sqrt{0.3375} \approx 0.581Take the square root.
Answer: E(X) = 9/4 = 2.25, Var(X) = 0.3375 (which is 27/80) and σ ≈ 0.581.
Example 2: Average quiz time (word problem)
The time X, in minutes, that a student takes to finish a 10-minute quiz has density f(x) = x/50 for 0 ≤ x ≤ 10. Find the mean time and its standard deviation.
E(X) = \int_0^{10} x \cdot \dfrac{x}{50}\,dx = \left[\dfrac{x^3}{150}\right]_0^{10}Multiply x by the density and integrate.
E(X) = \dfrac{1000}{150} = \dfrac{20}{3} \approx 6.67Evaluate and simplify.
E(X^2) = \int_0^{10} \dfrac{x^3}{50}\,dx = \left[\dfrac{x^4}{200}\right]_0^{10} = 50Multiply x² by the density, integrate and evaluate.
\operatorname{Var}(X) = 50 - \left(\dfrac{20}{3}\right)^2 = 50 - \dfrac{400}{9} = \dfrac{50}{9}Subtract the square of the mean.
\sigma = \sqrt{50/9} \approx 2.36Take the square root.
Answer: the mean time is about 6.67 minutes, with a standard deviation of about 2.36 minutes.
Example 3: A mean that needs integration by parts
X has density f(x) = 2e^(−2x) for x ≥ 0, and 0 elsewhere. Find E(X).
E(X) = \int_0^{\infty} x \cdot 2e^{-2x}\,dxMultiply x by the density.
u = x,\quad dv = 2e^{-2x}\,dxChoose the parts (see integration by parts).
du = dx,\quad v = -e^{-2x}Differentiate u and integrate dv.
E(X) = \lim_{b \to \infty}\left[-xe^{-2x}\right]_0^b + \int_0^{\infty} e^{-2x}\,dxUse uv minus the integral of v du.
\lim_{b \to \infty} \left(-be^{-2b}\right) = 0The exponential shrinks faster than b grows (see L’Hôpital’s rule).
\int_0^{\infty} e^{-2x}\,dx = \lim_{b \to \infty}\left[-\tfrac{1}{2}e^{-2x}\right]_0^b = \dfrac{1}{2}Evaluate the improper integral.
E(X) = 0 + \dfrac{1}{2} = \dfrac{1}{2}Add.
Answer: E(X) = 1/2.
Example 4: A finite mean with an infinite variance
X has density f(x) = 2/x³ for x ≥ 1, and 0 below 1. Find E(X) and decide whether Var(X) exists.
E(X) = \int_1^{\infty} x \cdot \dfrac{2}{x^3}\,dx = \int_1^{\infty} \dfrac{2}{x^2}\,dxMultiply x by the density.
E(X) = \lim_{b \to \infty}\left(2 - \dfrac{2}{b}\right) = 2Integrate and take the limit.
E(X^2) = \int_1^{\infty} x^2 \cdot \dfrac{2}{x^3}\,dx = \int_1^{\infty} \dfrac{2}{x}\,dxMultiply x² by the density.
E(X^2) = \lim_{b \to \infty} 2\ln b = \inftyThe integral diverges.
Answer: E(X) = 2, but E(X²) is infinite, so the variance does not exist. The tail of 2/x³ is thin enough for a mean but too heavy for a variance.
Example 5: The mean and spread of a cost
The length X, in centimeters, of a cut part has the density from Example 1. Each part costs C = 4X + 10 dollars to finish. Find E(C) and the standard deviation of C.
E(C) = 4E(X) + 10 = 4(2.25) + 10 = 19
Use the rule for E(aX + b).
E(C) = 4\int_0^3 \dfrac{x^3}{9}\,dx + 10\int_0^3 \dfrac{x^2}{9}\,dxCheck with the integral of (4x + 10)f(x), split into two integrals.
E(C) = 4\left(\tfrac{9}{4}\right) + 10(1) = 19The integrals are E(X) and the total area.
\operatorname{Var}(C) = 4^2 \operatorname{Var}(X) = 16(0.3375) = 5.4The added 10 shifts C but doesn’t change its spread.
\sigma_C = \sqrt{5.4} \approx 2.32Take the square root.
Answer: the expected cost is $19, with a standard deviation of about $2.32.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Leaving out the x | Writing E(X) = ∫ f(x) dx = 1 in Example 1 | Integrate x times the density: ∫ x·x²/9 dx = 9/4. |
| Forgetting to subtract μ² | Saying Var(X) = E(X²) = 5.4 in Example 1 | Var(X) = E(X²) − μ² = 5.4 − 5.0625 = 0.3375. |
| Subtracting μ instead of μ² | Var(X) = 5.4 − 2.25 = 3.15 in Example 1 | Square the mean first: 2.25² = 5.0625. |
| Applying a to the variance unsquared | Var(4X + 10) = 4(0.3375) + 10 in Example 5 | Var(aX + b) = a²Var(X); the constant b drops out: 16(0.3375) = 5.4. |
| Assuming every density has a variance | Reporting a variance for f(x) = 2/x³ in Example 4 | Check that each improper integral converges; here E(X²) is infinite. |
Related ideas
Mean and median
The median m solves F(m) = 1/2 (see cumulative distribution functions). In Example 1, m³/27 = 1/2 gives m ≈ 2.381, larger than the mean 2.25. The density is skewed left, so its long left tail pulls the mean below the median.
Expected value from the CDF
For a variable that is never negative, E(X) = ∫₀^∞ (1 − F(x)) dx. In Example 3, 1 − F(x) = e^(−2x), and its integral from 0 to ∞ is 1/2, matching the mean found by parts.
Moments
E(Xⁿ) is called the nth moment of X. The mean is the first moment, and the variance uses the first two. Moments of all orders can be packed into one function, which is the idea behind moment generating functions later in this course.
Practice problems
- X has density f(x) = 2x for 0 ≤ x ≤ 1. Find E(X).
- For the density in Problem 1, find Var(X).
- X has density f(x) = 3x² for 0 ≤ x ≤ 1. Find E(X).
- X has density f(x) = 1/4 for 2 ≤ x ≤ 6. Find E(X).
- X has density f(x) = 3/x⁴ for x ≥ 1. Find E(X).
- For the density in Problem 5, find Var(X).
- X has density f(x) = (3/32)(4 − x²) for −2 ≤ x ≤ 2. Find E(X).
- X has density f(x) = e^(−x) for x ≥ 0. Find E(X).
- X has mean 5 and variance 4. Find the mean and standard deviation of Y = 3X − 2.
- For the density in Problem 1, find E(1/X).
Show answers
1.
E(X) = \int_0^1 x \cdot 2x\,dx = \left[\dfrac{2x^3}{3}\right]_0^1 = \dfrac{2}{3}Multiply x by the density and integrate.
Answer: 2/3
2.
E(X^2) = \int_0^1 2x^3\,dx = \left[\dfrac{x^4}{2}\right]_0^1 = \dfrac{1}{2}Multiply x² by the density and integrate.
\operatorname{Var}(X) = \dfrac{1}{2} - \left(\dfrac{2}{3}\right)^2 = \dfrac{1}{2} - \dfrac{4}{9}Subtract the square of the mean.
\operatorname{Var}(X) = \dfrac{9}{18} - \dfrac{8}{18} = \dfrac{1}{18}Use a common denominator and subtract.
Answer: 1/18 ≈ 0.0556
3.
E(X) = \int_0^1 3x^3\,dx = \left[\dfrac{3x^4}{4}\right]_0^1 = \dfrac{3}{4}Multiply x by the density and integrate.
Answer: 3/4
4.
E(X) = \int_2^6 \dfrac{x}{4}\,dx = \left[\dfrac{x^2}{8}\right]_2^6Multiply x by the density and integrate.
E(X) = \dfrac{36}{8} - \dfrac{4}{8} = 4Evaluate at the limits and subtract.
Answer: 4, the midpoint of the interval
5.
E(X) = \int_1^{\infty} \dfrac{3}{x^3}\,dx = \lim_{b \to \infty}\left[-\dfrac{3}{2x^2}\right]_1^bMultiply x by the density and integrate.
E(X) = \lim_{b \to \infty}\left(\dfrac{3}{2} - \dfrac{3}{2b^2}\right) = \dfrac{3}{2}Take the limit.
Answer: 3/2
6.
E(X^2) = \int_1^{\infty} \dfrac{3}{x^2}\,dx = \lim_{b \to \infty}\left(3 - \dfrac{3}{b}\right) = 3Multiply x² by the density, integrate and take the limit.
\operatorname{Var}(X) = 3 - \left(\dfrac{3}{2}\right)^2 = 3 - \dfrac{9}{4} = \dfrac{3}{4}Subtract the square of the mean.
Answer: 3/4
7.
E(X) = \dfrac{3}{32}\int_{-2}^2 (4x - x^3)\,dx = \dfrac{3}{32}\left[2x^2 - \dfrac{x^4}{4}\right]_{-2}^2Multiply x by the density and integrate.
E(X) = \dfrac{3}{32}\left[(8 - 4) - (8 - 4)\right] = 0Evaluate at the limits.
Answer: 0, as expected, because the density is symmetric about 0
8.
E(X) = \lim_{b \to \infty}\left[-xe^{-x}\right]_0^b + \int_0^{\infty} e^{-x}\,dxIntegrate x e^(−x) by parts with u = x and v = −e^(−x).
E(X) = 0 + 1 = 1
The boundary term goes to 0, and the last integral is 1.
Answer: 1
9.
E(Y) = 3(5) - 2 = 13
Use E(aX + b) = aE(X) + b.
\operatorname{Var}(Y) = 3^2(4) = 36Use Var(aX + b) = a²Var(X).
\sigma_Y = \sqrt{36} = 6Take the square root.
Answer: mean 13, standard deviation 6
10.
E\left(\dfrac{1}{X}\right) = \int_0^1 \dfrac{1}{x} \cdot 2x\,dx = \int_0^1 2\,dxUse E(g(X)) with g(x) = 1/x.
E\left(\dfrac{1}{X}\right) = 2Integrate.
Answer: 2 (not 1/E(X) = 3/2)
Expected value of a continuous random variable FAQ
How do you find the expected value of a continuous random variable?
Multiply x by the density f(x) and integrate over every value X can take: E(X) = ∫ x f(x) dx. Use only the interval where the density is not 0.
How do you find the variance of a continuous random variable?
Find E(X²) = ∫ x² f(x) dx, then subtract the square of the mean: Var(X) = E(X²) − [E(X)]². The standard deviation is its square root.
Can the expected value be infinite?
Yes. If the integral of x f(x) diverges, the mean doesn’t exist; this happens for f(x) = 1/x² on x ≥ 1. A distribution can also have a mean but no variance, as in Example 4.
Is the expected value the same as the median?
Only for symmetric distributions. The mean is the balance point and the median splits the area in half, so a long tail pulls the mean toward it and away from the median.
Summary
- E(X) = ∫ x f(x) dx is the balance point of the density.
- E(g(X)) = ∫ g(x) f(x) dx for any function g.
- Var(X) = E(X²) − μ², and σ is its square root.
- E(aX + b) = aE(X) + b and Var(aX + b) = a²Var(X).
- Check that improper integrals converge; some densities have no mean or no variance.
Previous lesson: Cumulative Distribution Functions
Next lesson: Uniform Distribution
Back to the Probability Theory Index