S2 2.4 - Continuous expectation and variance

S2 2.4 - Continuous expectation and variance

Calculate a continuous distribution's mean and variance by weighting values with density. Use these moments alongside total probability to determine unknown parameters, and check that the resulting density remains valid.

Integrating for the mean

If a density rises from zero to two across [0,1][0,1], where is its average value of XX? The midpoint 1/21/2 ignores that values towards the right receive more probability. The mean accounts for those unequal weights.

For a discrete variable, you used ∑xP(X=x)\sum x\mathrm{P}(X=x). A thin strip near xx, of width Δx\Delta x, has probability approximately f(x)Δxf(x)\Delta x. Its contribution to the weighted average is approximately xf(x)Δxxf(x)\Delta x. Taking all strips gives an integral.

Continuous expectation

For a variable with density ff,

E(X)=∫−∞∞xf(x) dx.\mathrm{E}(X)=\int_{-\infty}^{\infty}xf(x)\,\mathrm{d}x.

More generally,

E(g(X))=∫−∞∞g(x)f(x) dx.\mathrm{E}(g(X))=\int_{-\infty}^{\infty}g(x)f(x)\,\mathrm{d}x.

These formulae are in the formula booklet. Integrate on the support, splitting at any changes of formula.

The mean is a weighted average of possible values, so for the bounded distributions here it must lie between the support endpoints. It need not equal the median or the mode.

Worked example 1: an increasing density

Find the mean for density f(x)=2xf(x)=2x on [0,1][0,1], zero otherwise.

Plan. Multiply the density by xx before integrating over the support.

E(X)=∫01x(2x) dx=[2x33]01=23.\mathrm{E}(X)=\int_0^1x(2x)\,\mathrm{d}x =\left[\frac{2x^3}{3}\right]_0^1=\frac23.

Answer. E(X)=2/3\mathrm{E}(X)=2/3.

Check. It lies within [0,1][0,1] and to the right of the midpoint, where the greater density makes that reasonable. Independently, ∫01(x−2/3)2x dx=2/3−2/3=0\int_0^1(x-2/3)2x\,\mathrm{d}x=2/3-2/3=0, so signed deviations balance.

Move the lower support boundary to one while keeping the density proportional to xx. Normalisation changes the coefficient, so do not simply shift the old mean.

Worked example 2: a changed support

Find the mean for density f(x)=2x/3f(x)=2x/3 on [1,2][1,2], zero otherwise.

Plan. Use the actual support in the weighted integral.

E(X)=∫12x2x3 dx=[2x39]12=16−29=149.\mathrm{E}(X)=\int_1^2x\frac{2x}{3}\,\mathrm{d}x =\left[\frac{2x^3}{9}\right]_1^2 =\frac{16-2}{9}=\frac{14}{9}.

Answer. E(X)=14/9≈1.56\mathrm{E}(X)=14/9\approx1.56.

Check. The density's total area is [x2/3]12=1[x^2/3]_1^2=1. Its mean lies inside the support and above its midpoint 1.51.5, consistent with the increasing density.

For a transformation, use g(x)g(x) rather than replacing the density. For example, E(2X+1)=∫(2x+1)f(x) dx=2E(X)+1\mathrm{E}(2X+1)=\int(2x+1)f(x)\,\mathrm{d}x=2\mathrm{E}(X)+1, because ∫f(x) dx=1\int f(x)\,\mathrm{d}x=1.

A piecewise density needs the same weighting on every branch. The extra step is splitting the integral, rather than changing the definition of the mean.

Worked example 3: a piecewise mean

Find the mean for density f(x)=xf(x)=x on [0,1][0,1], f(x)=1/2f(x)=1/2 on (1,2](1,2], and zero otherwise.

Plan. Multiply each density branch by xx, integrate on its own interval, then add.

E(X)=∫01x(x) dx+∫12x(12) dx=[x33]01+[x24]12=13+34=1312.\begin{aligned} \mathrm{E}(X) &=\int_0^1 x(x)\,\mathrm{d}x+\int_1^2 x\left(\frac12\right)\,\mathrm{d}x\\ &=\left[\frac{x^3}{3}\right]_0^1+\left[\frac{x^2}{4}\right]_1^2\\ &=\frac13+\frac34=\frac{13}{12}. \end{aligned}

Answer. 13/1213/12.

Check. The two contributions to the integral of (x−13/12)f(x)(x-13/12)f(x) are −5/24-5/24 and 5/245/24. They cancel, so signed deviations from this mean balance across the two pieces.

The factor xx is needed in both branches, just as it was for a single density formula.

Watch out

∫f(x) dx\int f(x)\,\mathrm{d}x over the full support gives one, not the mean. The mean requires the factor xx.

Weight both pieces of a new density in the same way.

Second moments and variance

Variance weights squared distances from the mean, and an equivalent second-moment formula usually makes it easier to calculate.

Expand (x−μ)2=x2−2μx+μ2(x-\mu)^2=x^2-2\mu x+\mu^2, multiply by f(x)f(x) and integrate. Since ∫xf(x) dx=μ\int xf(x)\,\mathrm{d}x=\mu and ∫f(x) dx=1\int f(x)\,\mathrm{d}x=1, the result is E(X2)−μ2\mathrm{E}(X^2)-\mu^2.

Second moment and variance

E(X2)=∫−∞∞x2f(x) dx,\mathrm{E}(X^2)=\int_{-\infty}^{\infty}x^2f(x)\,\mathrm{d}x, Var(X)=E(X2)−{E(X)}2=∫−∞∞(x−μ)2f(x) dx.\mathrm{Var}(X)=\mathrm{E}(X^2)-\{\mathrm{E}(X)\}^2 =\int_{-\infty}^{\infty}(x-\mu)^2f(x)\,\mathrm{d}x.

In the formula booklet. The standard deviation is the square root of the variance.

The second moment squares the value xx, not the density. Squaring f(x)f(x) would give the wrong weighting and would not calculate E(X2)\mathrm{E}(X^2).

Continue this lesson.

You’re previewing NovaLearn without an account. Create a free account to read the rest.

Create free account