How the mean and variance of a continuous variable become integrals against its density, how the law of the unconscious statistician and mixed distributions fit in, and when a moment is infinite or fails to exist.
A measurement X described by a density on [0,1] gives probability 0 to each single value, so its average cannot be found by listing values and their probabilities. Cut the range into narrow strips instead. A strip of width Δx near x has probability close to f(x)Δx, and it adds about xf(x)Δx to the weighted average, so letting the strips shrink replaces the sum by an integral. This lesson defines continuous expectation and variance in this way, extends them to functions of X and to mixed distributions, and shows why a valid density need not have a finite mean.
Key terms
Expected value of a continuous variable
Definition Let X have density f. If
∫−∞∞∣x∣f(x)dx<∞,
the expected value of X is the finite number
E[X]=∫−∞∞xf(x)dx.
It is also called the mean, often written μ, and it has the units of X. When f is 0 outside a bounded interval [a,b], the condition holds automatically and a≤E[X]≤b. When f(x)=0 for all x<0, the integral of xf(x) is either a finite number or +∞, and in the second case we write E[X]=+∞.
In plain words The mean is the same weighted average as for a discrete variable, with density times a small width in the role of a mass. It is the balance point of the distribution, not a forecast of one observation, and it need not equal the median.
Example Let X have density f(x)=2x for 0≤x≤1 and f(x)=0 otherwise. The total area is ∫012xdx=1, and
E[X]=∫01x⋅2xdx=[32x3]01=32.
The density rises to the right, so the mean lies to the right of 21. The CDF is F(x)=x2 on [0,1], so P(X≤32)=94, and the median is 1/2≈0.707, not the mean.
Law of the unconscious statistician
Definition Let X have density f, and let g be a function such as a polynomial or a piecewise continuous function. If ∫−∞∞∣g(x)∣f(x)dx<∞, then
E[g(X)]=∫−∞∞g(x)f(x)dx.
If g≥0, the formula holds without that condition, with both sides possibly equal to +∞. In particular, the kth moment E[Xk] is the integral of xkf(x), finite when the integral of ∣x∣kf(x) is finite, and E[X2] is the second moment. The rule is called the law of the unconscious statistician, or LOTUS, because it is easy to use without noticing that it needs proof.
In plain words To average a function of X, weight the values of the function by the original density. There is no need to find the distribution of g(X) first. The function is applied inside the integral, not to the answer, so E[g(X)] is usually different from g(E[X]).
Example For the density 2x on [0,1],
E[X2]=∫01x2⋅2xdx=[21x4]01=21,
which is not (E[X])2=94. As a check, Y=X2 has P(Y≤y)=P(X≤y)=y for 0≤y≤1, so Y∼Uniform(0,1), and its mean is ∫01ydy=21. LOTUS gave the same answer without that detour.
Variance of a continuous variable
Definition Let X have density f and finite mean μ. The variance of X is
Var(X)=E[(X−μ)2]=∫−∞∞(x−μ)2f(x)dx,
a number in [0,∞) or +∞. It is finite exactly when E[X2]<∞, and then
Var(X)=E[X2]−μ2.
The standard deviation is SD(X)=Var(X). Variance has the squared units of X, and the standard deviation has the units of X. When Var(X) is finite, the rules Var(a+bX)=b2Var(X) and SD(a+bX)=∣b∣SD(X) hold for all constants a and b. A variable with a density and a finite mean has Var(X)>0, because variance 0 would force P(X=μ)=1.
In plain words Variance is the average squared distance from the mean, weighted by the density. Squaring removes signs and stresses large distances, so variance is not the average absolute distance. The shortcut E[X2]−μ2 is convenient when both moments are finite, and it shows that the average of the squares exceeds the square of the average by exactly the variance.
Example For the density 2x on [0,1],
Var(X)=21−(32)2=21−94=181,
and SD(X)=1/18≈0.236. The direct integral ∫01(x−32)22xdx gives the same 181. If X is measured in hours, the variance is in squared hours and the standard deviation in hours. The recorded quantity Y=10+6X has E[Y]=10+6⋅32=14 and Var(Y)=36⋅181=2, so SD(Y)=2≈1.414. Adding 10 moves the mean and leaves the spread alone.
Mean of a mixed distribution
Definition Let X have a mixed distribution with atoms ai of masses mi and a continuous part h≥0 whose total area is 1−M, where M=∑imi. For a function g such that ∑i∣g(ai)∣mi and ∫∣g(x)∣h(x)dx are finite,
E[g(X)]=i∑g(ai)mi+∫−∞∞g(x)h(x)dx.
In particular, E[X] is M times the mean of the discrete part plus 1−M times the mean of the continuous part, a weighted average of the two conditional means. The variance is E[X2]−(E[X])2 with both moments found this way. It is at least the weighted average of the two conditional variances, and larger whenever the two conditional means differ.
In plain words Each piece contributes in proportion to its own weight. The atoms contribute their values times their masses, and the continuous part contributes an integral against h, whose total area is less than 1. Leaving out an atom, or treating the continuous part as the whole distribution, describes a different model.
Example Let T equal 0 with probability 0.2 and otherwise be uniform on (0,1), so h(t)=0.8 on (0,1). The atom contributes 0⋅0.2=0 to each moment, so
E[T]=∫01t⋅0.8dt=52,E[T2]=∫01t2⋅0.8dt=154.
Then Var(T)=154−254=758≈0.107. Ignoring the atom would give the mean 21 and the variance 121≈0.083 of the continuous part alone. The atom pulls the mean down, and the gap between the conditional means 0 and 21 adds spread.
Infinite mean
Definition Let X have a density f with f(x)=0 for all x<0. If the integral of xf(x) over [0,∞) diverges, then X has infinite mean, written E[X]=+∞. The density still has total area 1. Normalization fixes the area under f and says nothing about the integral of xf(x). An infinite mean requires X to be unbounded, meaning P(X>t)>0 for every t.
In plain words Every single value of X is finite, but large values keep so much probability that the weighted average grows without bound as more of the range is included. The mean is then not some very large number. No finite number serves as the balance point.
Example Let f(x)=1/x2 for x≥1 and f(x)=0 for x<1. For b>1, ∫1bx−2dx=1−1/b, which tends to 1, so f is a density. But
∫1bx⋅x21dx=∫1bxdx=lnb,
which grows without bound. Without logarithms, on each interval from 2k to 2k+1 the integrand 1/x is at least 1/2k+1 over a width 2k, so each such interval adds at least 21, and infinitely many halves have no finite sum. Hence E[X]=+∞, even though P(X>t)=1/t for t≥1, which tends to 0, and the median is 2.
Moment existence
Definition Let X have density f. The kth moment E[Xk] exists as a finite number when
∫−∞∞∣x∣kf(x)dx<∞.
For k=1 this condition is called absolute integrability, and it is exactly what makes E[X] a finite number. If the positive part ∫0∞xf(x)dx and the negative part ∫−∞0∣x∣f(x)dx are both infinite, E[X] is undefined. If exactly one of them is infinite, E[X] is +∞ or −∞. A finite second moment gives a finite mean, because ∣x∣≤1+x2, and the variance is finite exactly when the second moment is. A density that is 0 outside a bounded interval has finite moments of every order.
In plain words Before using a moment, check that the integral of its absolute size is finite. Symmetry alone does not supply a mean. When both tails carry infinite weight, canceling them against each other over [−R,R] produces a number that depends on how the limits are taken, so it is not an expectation.
Example The density f(x)=1/(2x2) for ∣x∣≥1, and 0 for ∣x∣<1, has total area 1 and is symmetric about 0. Every symmetric integral ∫−RRxf(x)dx is 0, but
∫−∞∞∣x∣f(x)dx=∫1∞xdx=∞,
and integrating over [−R,2R] instead gives 21ln2 for every R≥1. So E[X] is undefined, although 0 is the center of symmetry and a median. For a finite mean with infinite variance, take f(x)=2/x3 for x≥1 and 0 otherwise. Its total area is 1, its mean is ∫1∞2x−2dx=2, and its second moment is ∫1∞2x−1dx=+∞, so Var(X)=+∞.
Check yourself
Let X have density f(x)=3x2 for 0≤x≤1 and 0 otherwise. Find E[X], E[X2], Var(X) and SD(X).
Show the answer
The total area is ∫013x2dx=1, and the support is bounded, so every moment is finite. By LOTUS,
E[X]=∫013x3dx=43,E[X2]=∫013x4dx=53.
With the common denominator 80,
Var(X)=53−169=8048−8045=803,
and SD(X)=3/80≈0.194.
For the same X, find the mean, variance and standard deviation of Y=5−2X. A classmate writes Var(Y)=−2Var(X). What went wrong?
Show the answer
By linearity, E[Y]=5−2⋅43=27. Adding 5 does not change the spread, and multiplying by −2 multiplies the variance by (−2)2=4, so
Var(Y)=4⋅803=203,
and SD(Y)=∣−2∣SD(X)=3/20≈0.387. The classmate’s value −2⋅803=−403 is negative, which no average of squared distances can be. The factor −2 reverses the direction of the scale, but distances from the mean are doubled and their squares are multiplied by 4.
Let X have density f(x)=3x−4 for x≥1 and 0 for x<1. Check that f is a density, find E[X] and Var(X), and decide whether E[X3] is finite.
Show the answer
The function is nonnegative, and for b>1, ∫1b3x−4dx=1−b−3, which tends to 1. So f is a density. Since X≥1, every moment integral has a nonnegative integrand and is either finite or +∞. Here
E[X]=∫1∞3x−3dx=23,E[X2]=∫1∞3x−2dx=3,
so Var(X)=3−49=43. The third moment is ∫1∞3x−1dx, and since ∫1b3x−1dx=3lnb grows without bound, E[X3]=+∞. This variable has a finite mean and a finite variance but an infinite third moment, so finite lower moments do not guarantee a finite higher one.
May we count page visits to understand which courses and learning features are useful? Cloudflare collects visit and performance statistics, without your account details or answers. Your choice does not affect access. Details