Mean and Variance of Continuous Random Variables

A2 · S2 · 9 min

The mean and variance of a continuous random variable answer the same questions as for a discrete one: where is the centre of the distribution, and how spread out is it? The only change is that sums become integrals. Every Paper 6 continuous random variable question asks for at least one of E(X)E(X) and Var(X)\text{Var}(X), and the formulas are in the formula booklet, so the marks are earned by setting up the integrals correctly and carrying out the integration accurately.

From sums to integrals

For a discrete random variable,

E(X)=∑x P(X=x),Var(X)=∑x2P(X=x)−[E(X)]2.E(X) = \sum x\,P(X = x), \qquad \text{Var}(X) = \sum x^2 P(X = x) - [E(X)]^2.

Each value is weighted by its probability. For a continuous variable, a thin strip of width δx\delta x around the value xx has probability approximately f(x) δxf(x)\,\delta x. Weighting each xx by that and adding over all strips gives an integral.

Key result

For a continuous random variable XX with probability density function f(x)f(x):

E(X)=∫x f(x) dxE(X) = \int x\,f(x)\,dxVar(X)=∫x2f(x) dx−[E(X)]2=E(X2)−[E(X)]2\text{Var}(X) = \int x^2 f(x)\,dx - [E(X)]^2 = E(X^2) - [E(X)]^2

The integrals are taken over the interval on which ff is defined. Both formulas are in MF19.

The mean E(X)E(X) is the balance point of the region under the curve: if the region were cut out of card, it would balance on a pivot at x=E(X)x = E(X).

Mean and variance from a pdf
  1. Multiply f(x)f(x) by xx, expand, and integrate over the interval: this is E(X)E(X).
  2. Multiply f(x)f(x) by x2x^2, expand, and integrate over the interval: this is E(X2)E(X^2).
  3. Var(X)=E(X2)−[E(X)]2\text{Var}(X) = E(X^2) - [E(X)]^2. Do not forget to subtract the square of the mean.
  4. Check: the mean lies inside the interval, and the variance is positive. The standard deviation is Var(X)\sqrt{\text{Var}(X)}.
A routine mean and variance

The random variable XX has probability density function f(x)=x29f(x) = \dfrac{x^2}{9} for 0≤x≤30 \le x \le 3, and 00 otherwise. Find E(X)E(X) and Var(X)\text{Var}(X).

SolutionE(X)=∫03x⋅x29 dx=19[x44]03=8136=2.25E(X) = \int_0^3 x \cdot \frac{x^2}{9}\,dx = \frac{1}{9}\left[\frac{x^4}{4}\right]_0^3 = \frac{81}{36} = 2.25E(X2)=∫03x2⋅x29 dx=19[x55]03=24345=5.4E(X^2) = \int_0^3 x^2 \cdot \frac{x^2}{9}\,dx = \frac{1}{9}\left[\frac{x^5}{5}\right]_0^3 = \frac{243}{45} = 5.4Var(X)=5.4−2.252=5.4−5.0625=0.3375\text{Var}(X) = 5.4 - 2.25^2 = 5.4 - 5.0625 = 0.3375

The mean 2.252.25 is towards the right of [0,3][0, 3], which makes sense: the density increases with xx, so more of the probability is at the upper end.

Symmetry: the mean for free

If the graph of ff is symmetric about the line x=cx = c, the balance point is cc, so E(X)=cE(X) = c with no integration. Typical symmetric densities are kx(a−x)kx(a - x) on [0,a][0, a] (symmetric about a2\frac{a}{2}), k(a2−x2)k(a^2 - x^2) on [−a,a][-a, a] (symmetric about 00), and constant densities.

If the question says "state" or "write down" the mean, symmetry is what is wanted. If it says "find", a sentence quoting the symmetry is still acceptable, but the variance must always be integrated.

Using symmetry

XX has probability density function f(x)=332x(4−x)f(x) = \dfrac{3}{32}x(4 - x) for 0≤x≤40 \le x \le 4, and 00 otherwise.

(a) Write down E(X)E(X).

(b) Find Var(X)\text{Var}(X).

Solution

(a) The graph of ff is symmetric about x=2x = 2, so E(X)=2E(X) = 2.

(b)

E(X2)=332∫04(4x3−x4) dx=332[x4−x55]04=332(256−10245)=332×2565=4.8E(X^2) = \frac{3}{32}\int_0^4 (4x^3 - x^4)\,dx = \frac{3}{32}\left[x^4 - \frac{x^5}{5}\right]_0^4 = \frac{3}{32}\left(256 - \frac{1024}{5}\right) = \frac{3}{32} \times \frac{256}{5} = 4.8Var(X)=4.8−22=0.8\text{Var}(X) = 4.8 - 2^2 = 0.8

Infinite intervals and exponentials

The same formulas work on infinite intervals, using improper integrals. Exponential densities need integration by parts from Pure 3, which the syllabus assumes.

An infinite interval

XX has probability density function f(x)=3x4f(x) = \dfrac{3}{x^4} for x≥1x \ge 1, and 00 otherwise. Find the mean and the standard deviation of XX.

SolutionE(X)=∫1∞x⋅3x−4 dx=∫1∞3x−3 dx=[−32x2]1∞=0+32=1.5E(X) = \int_1^\infty x \cdot 3x^{-4}\,dx = \int_1^\infty 3x^{-3}\,dx = \left[-\frac{3}{2x^2}\right]_1^\infty = 0 + \frac{3}{2} = 1.5E(X2)=∫1∞3x−2 dx=[−3x]1∞=3E(X^2) = \int_1^\infty 3x^{-2}\,dx = \left[-\frac{3}{x}\right]_1^\infty = 3Var(X)=3−1.52=0.75,standard deviation=0.75=0.866\text{Var}(X) = 3 - 1.5^2 = 0.75, \qquad \text{standard deviation} = \sqrt{0.75} = 0.866
An exponential density

The waiting time TT minutes has probability density function f(t)=12e−t/2f(t) = \tfrac{1}{2}e^{-t/2} for t≥0t \ge 0, and 00 otherwise. Find E(T)E(T) and Var(T)\text{Var}(T).

Solution

By parts, with u=tu = t and dvdt=12e−t/2\dfrac{dv}{dt} = \tfrac{1}{2}e^{-t/2}, so v=−e−t/2v = -e^{-t/2}:

E(T)=∫0∞t⋅12e−t/2 dt=[−te−t/2]0∞+∫0∞e−t/2 dt=0+[−2e−t/2]0∞=2E(T) = \int_0^\infty t \cdot \tfrac{1}{2}e^{-t/2}\,dt = \left[-te^{-t/2}\right]_0^\infty + \int_0^\infty e^{-t/2}\,dt = 0 + \left[-2e^{-t/2}\right]_0^\infty = 2

The term te−t/2→0te^{-t/2} \to 0 as t→∞t \to \infty because the exponential decays faster than tt grows.

For E(T2)E(T^2), with u=t2u = t^2, v=−e−t/2v = -e^{-t/2}:

E(T2)=[−t2e−t/2]0∞+∫0∞2te−t/2 dt=0+4∫0∞t⋅12e−t/2 dt=4E(T)=8E(T^2) = \left[-t^2e^{-t/2}\right]_0^\infty + \int_0^\infty 2te^{-t/2}\,dt = 0 + 4\int_0^\infty t \cdot \tfrac{1}{2}e^{-t/2}\,dt = 4E(T) = 8Var(T)=8−22=4\text{Var}(T) = 8 - 2^2 = 4

Linear transformations

The expectation and variance rules from linear combinations of random variables apply to continuous variables too:

E(aX+b)=aE(X)+b,Var(aX+b)=a2 Var(X).E(aX + b) = aE(X) + b, \qquad \text{Var}(aX + b) = a^2\,\text{Var}(X).

So once you have E(X)E(X) and Var(X)\text{Var}(X), you never need to integrate again for a scaled or shifted version.

More generally, the mean of any function of XX is found by weighting that function by the density: E(g(X))=∫g(x)f(x) dxE(g(X)) = \displaystyle\int g(x)f(x)\,dx. E(X2)E(X^2) is the special case g(x)=x2g(x) = x^2. You will occasionally need, for example, E(1X)E\left(\frac{1}{X}\right), but this is rare.

Unknown constants from the mean

If a density has two unknown constants and you are given the mean, you get two equations: total area =1= 1 and ∫xf(x) dx=\int x f(x)\,dx = given mean.

An exam-style question

The random variable XX has probability density function f(x)=a+bxf(x) = a + bx for 0≤x≤10 \le x \le 1, and 00 otherwise. It is given that E(X)=712E(X) = \dfrac{7}{12}.

(a) Find the values of aa and bb.

(b) Find Var(X)\text{Var}(X).

(c) Find E(3X+2)E(3X + 2) and Var(3X+2)\text{Var}(3X + 2).

(d) Find P(X>E(X))P(X > E(X)).

Solution

(a) Total area:

∫01(a+bx) dx=a+b2=1\int_0^1 (a + bx)\,dx = a + \frac{b}{2} = 1

Mean:

∫01(ax+bx2) dx=a2+b3=712\int_0^1 (ax + bx^2)\,dx = \frac{a}{2} + \frac{b}{3} = \frac{7}{12}

From the first, a=1−b2a = 1 - \dfrac{b}{2}. Substituting: 12−b4+b3=712\dfrac{1}{2} - \dfrac{b}{4} + \dfrac{b}{3} = \dfrac{7}{12}, so b12=112\dfrac{b}{12} = \dfrac{1}{12}, giving b=1b = 1 and a=12a = \dfrac{1}{2}.

(b)

E(X2)=∫01(12x2+x3)dx=16+14=512E(X^2) = \int_0^1 \left(\tfrac{1}{2}x^2 + x^3\right)dx = \frac{1}{6} + \frac{1}{4} = \frac{5}{12}Var(X)=512−(712)2=60144−49144=11144=0.0764\text{Var}(X) = \frac{5}{12} - \left(\frac{7}{12}\right)^2 = \frac{60}{144} - \frac{49}{144} = \frac{11}{144} = 0.0764

(c)

E(3X+2)=3×712+2=3.75,Var(3X+2)=9×11144=1116=0.6875E(3X + 2) = 3 \times \frac{7}{12} + 2 = 3.75, \qquad \text{Var}(3X + 2) = 9 \times \frac{11}{144} = \frac{11}{16} = 0.6875

(d)

P(X>712)=∫7/121(12+x)dx=[x2+x22]7/121=1−(724+49288)=155288=0.538P\left(X > \tfrac{7}{12}\right) = \int_{7/12}^1 \left(\tfrac{1}{2} + x\right)dx = \left[\frac{x}{2} + \frac{x^2}{2}\right]_{7/12}^1 = 1 - \left(\frac{7}{24} + \frac{49}{288}\right) = \frac{155}{288} = 0.538

The probability of exceeding the mean is not 0.50.5. The density rises to the right, so the mean and the median are not the same point. This contrast is explored in median and percentiles.

Common mistakes
  • Forgetting to square the mean. Var(X)=E(X2)−[E(X)]2\text{Var}(X) = E(X^2) - [E(X)]^2, not E(X2)−E(X)E(X^2) - E(X).
  • Integrating f(x)f(x) instead of xf(x)xf(x). ∫f(x) dx=1\int f(x)\,dx = 1 always; that is not the mean.
  • Multiplying only one term by xx. For f(x)=332(4x−x2)f(x) = \frac{3}{32}(4x - x^2), xf(x)=332(4x2−x3)xf(x) = \frac{3}{32}(4x^2 - x^3). Expand first, then integrate.
  • Writing E(X2)=[E(X)]2E(X^2) = [E(X)]^2. These are different; their difference is the variance.
  • Losing the constant. Keep 332\frac{3}{32} (or kk) outside the integral and remember to multiply by it at the end.
  • A negative variance. This always means an arithmetic or setup error. Check it before moving on.
Exam tip
  • The formulas are given in MF19, so the marks are for the integral with the correct integrand and limits, the integration, and the arithmetic. Write ∫03x⋅x29 dx\displaystyle\int_0^3 x \cdot \frac{x^2}{9}\,dx before you integrate.
  • Exact fractions (11144\frac{11}{144}) are ideal. If you give a decimal, give at least 3 significant figures.
  • "Show that E(X)=…E(X) = \dots" questions need every step, including substituting limits.
  • If the question says "state the value of E(X)E(X)", the answer is by symmetry: give a reason ("by symmetry of the graph about x=2x = 2").
  • Expect the next part to ask for a median or a probability involving the mean, such as P(X>μ)P(X > \mu). Use the unrounded mean.
Summary
  • E(X)=∫xf(x) dxE(X) = \int x f(x)\,dx and E(X2)=∫x2f(x) dxE(X^2) = \int x^2 f(x)\,dx, over the interval where ff is defined.
  • Var(X)=E(X2)−[E(X)]2\text{Var}(X) = E(X^2) - [E(X)]^2.
  • Symmetry about x=cx = c gives E(X)=cE(X) = c immediately.
  • Infinite intervals and exponential densities: improper integrals and integration by parts.
  • E(aX+b)=aE(X)+bE(aX + b) = aE(X) + b; Var(aX+b)=a2Var(X)\text{Var}(aX + b) = a^2\text{Var}(X).
  • Two unknown constants: use total area =1= 1 together with a given mean or probability.

Practice questions

Question
  1. f(x)=14(x+1)f(x) = \tfrac{1}{4}(x + 1) for 0≤x≤20 \le x \le 2, and 00 otherwise. Find E(X)E(X) and Var(X)\text{Var}(X).
  2. f(x)=4x5f(x) = \dfrac{4}{x^5} for x≥1x \ge 1, and 00 otherwise. Find E(X)E(X) and Var(X)\text{Var}(X).
  3. f(x)=15f(x) = \tfrac{1}{5} for 2≤x≤72 \le x \le 7, and 00 otherwise. Write down E(X)E(X) and find Var(X)\text{Var}(X).
  4. f(x)=38x2f(x) = \tfrac{3}{8}x^2 for 0≤x≤20 \le x \le 2, and 00 otherwise. Find E(X)E(X) and Var(X)\text{Var}(X), and hence find E(4X−1)E(4X - 1) and Var(4X−1)\text{Var}(4X - 1).
  5. f(x)=34(1−x2)f(x) = \tfrac{3}{4}(1 - x^2) for −1≤x≤1-1 \le x \le 1, and 00 otherwise. State E(X)E(X) and find the standard deviation of XX.
  6. f(x)=2e−2xf(x) = 2e^{-2x} for x≥0x \ge 0, and 00 otherwise. Find E(X)E(X) and Var(X)\text{Var}(X).
  7. f(x)=ax+bx2f(x) = ax + bx^2 for 0≤x≤10 \le x \le 1, and 00 otherwise, where aa and bb are constants. Given that E(X)=0.7E(X) = 0.7, find aa and bb, and find Var(X)\text{Var}(X).
  8. f(x)=cos⁡xf(x) = \cos x for 0≤x≤π20 \le x \le \frac{\pi}{2}, and 00 otherwise. Show that E(X)=π2−1E(X) = \frac{\pi}{2} - 1 and that Var(X)=π−3\text{Var}(X) = \pi - 3.
Answers
  1. E(X)=14∫02(x2+x) dx=14(83+2)=76E(X) = \tfrac{1}{4}\displaystyle\int_0^2 (x^2 + x)\,dx = \tfrac{1}{4}\left(\tfrac{8}{3} + 2\right) = \tfrac{7}{6}. E(X2)=14∫02(x3+x2) dx=14(4+83)=53E(X^2) = \tfrac{1}{4}\displaystyle\int_0^2 (x^3 + x^2)\,dx = \tfrac{1}{4}\left(4 + \tfrac{8}{3}\right) = \tfrac{5}{3}. Var(X)=53−4936=1136=0.306\text{Var}(X) = \tfrac{5}{3} - \tfrac{49}{36} = \tfrac{11}{36} = 0.306.

  2. E(X)=∫1∞4x−4 dx=[−43x3]1∞=43E(X) = \displaystyle\int_1^\infty 4x^{-4}\,dx = \left[-\tfrac{4}{3x^3}\right]_1^\infty = \tfrac{4}{3}. E(X2)=∫1∞4x−3 dx=[−2x2]1∞=2E(X^2) = \displaystyle\int_1^\infty 4x^{-3}\,dx = \left[-\tfrac{2}{x^2}\right]_1^\infty = 2. Var(X)=2−169=29\text{Var}(X) = 2 - \tfrac{16}{9} = \tfrac{2}{9}.

  3. By symmetry E(X)=4.5E(X) = 4.5. E(X2)=15[x33]27=115(343−8)=673E(X^2) = \tfrac{1}{5}\left[\tfrac{x^3}{3}\right]_2^7 = \tfrac{1}{15}(343 - 8) = \tfrac{67}{3}. Var(X)=673−4.52=2512=2.08\text{Var}(X) = \tfrac{67}{3} - 4.5^2 = \tfrac{25}{12} = 2.08.

  4. E(X)=38[x44]02=1.5E(X) = \tfrac{3}{8}\left[\tfrac{x^4}{4}\right]_0^2 = 1.5; E(X2)=38[x55]02=38×325=2.4E(X^2) = \tfrac{3}{8}\left[\tfrac{x^5}{5}\right]_0^2 = \tfrac{3}{8} \times \tfrac{32}{5} = 2.4; Var(X)=2.4−2.25=0.15\text{Var}(X) = 2.4 - 2.25 = 0.15. E(4X−1)=5E(4X - 1) = 5; Var(4X−1)=16×0.15=2.4\text{Var}(4X - 1) = 16 \times 0.15 = 2.4.

  5. By symmetry about x=0x = 0, E(X)=0E(X) = 0. E(X2)=34∫−11(x2−x4) dx=34(23−25)=15E(X^2) = \tfrac{3}{4}\displaystyle\int_{-1}^1 (x^2 - x^4)\,dx = \tfrac{3}{4}\left(\tfrac{2}{3} - \tfrac{2}{5}\right) = \tfrac{1}{5}, so Var(X)=15\text{Var}(X) = \tfrac{1}{5} and the standard deviation is 0.2=0.447\sqrt{0.2} = 0.447.

  6. By parts, E(X)=[−xe−2x]0∞+∫0∞e−2x dx=0+12=12E(X) = \left[-xe^{-2x}\right]_0^\infty + \displaystyle\int_0^\infty e^{-2x}\,dx = 0 + \tfrac{1}{2} = \tfrac{1}{2}. E(X2)=[−x2e−2x]0∞+∫0∞2xe−2x dx=0+E(X)=12E(X^2) = \left[-x^2e^{-2x}\right]_0^\infty + \displaystyle\int_0^\infty 2xe^{-2x}\,dx = 0 + E(X) = \tfrac{1}{2}. Var(X)=12−14=14\text{Var}(X) = \tfrac{1}{2} - \tfrac{1}{4} = \tfrac{1}{4}.

  7. Area: a2+b3=1\tfrac{a}{2} + \tfrac{b}{3} = 1. Mean: a3+b4=0.7\tfrac{a}{3} + \tfrac{b}{4} = 0.7. Multiply the first by 66: 3a+2b=63a + 2b = 6. Multiply the second by 1212: 4a+3b=8.44a + 3b = 8.4. Solving: a=1.2a = 1.2, b=1.2b = 1.2. (Check: f(x)=1.2x+1.2x2≥0f(x) = 1.2x + 1.2x^2 \ge 0 on [0,1][0, 1].) E(X2)=a4+b5=0.3+0.24=0.54E(X^2) = \tfrac{a}{4} + \tfrac{b}{5} = 0.3 + 0.24 = 0.54; Var(X)=0.54−0.49=0.05\text{Var}(X) = 0.54 - 0.49 = 0.05.

  8. E(X)=∫0π/2xcos⁡x dx=[xsin⁡x]0π/2−∫0π/2sin⁡x dx=π2−[−cos⁡x]0π/2=π2−1E(X) = \displaystyle\int_0^{\pi/2} x\cos x\,dx = [x\sin x]_0^{\pi/2} - \displaystyle\int_0^{\pi/2}\sin x\,dx = \tfrac{\pi}{2} - [-\cos x]_0^{\pi/2} = \tfrac{\pi}{2} - 1. E(X2)=∫0π/2x2cos⁡x dx=[x2sin⁡x]0π/2−∫0π/22xsin⁡x dxE(X^2) = \displaystyle\int_0^{\pi/2} x^2\cos x\,dx = [x^2\sin x]_0^{\pi/2} - \displaystyle\int_0^{\pi/2} 2x\sin x\,dx. ∫0π/22xsin⁡x dx=[−2xcos⁡x]0π/2+∫0π/22cos⁡x dx=0+2=2\displaystyle\int_0^{\pi/2} 2x\sin x\,dx = [-2x\cos x]_0^{\pi/2} + \displaystyle\int_0^{\pi/2} 2\cos x\,dx = 0 + 2 = 2, so E(X2)=π24−2E(X^2) = \tfrac{\pi^2}{4} - 2. Var(X)=π24−2−(π2−1)2=π24−2−π24+π−1=π−3\text{Var}(X) = \tfrac{\pi^2}{4} - 2 - \left(\tfrac{\pi}{2} - 1\right)^2 = \tfrac{\pi^2}{4} - 2 - \tfrac{\pi^2}{4} + \pi - 1 = \pi - 3.

How well do you know this?

Builds on

Where this leads

Console

Search notes, courses and tools, or run an action