Expectation, variance and inequalities
The lesson "The Lebesgue integral" defined for any measurable function on any measure space, and "Random variables and their distributions" turned a random experiment into a number with a distribution on the real line. This lesson joins the two. The expectation of a random variable is its Lebesgue integral under the probability measure, so everything proved about integrals earlier becomes a statement about averages of random quantities. Three questions drive the lesson: what a number such as for a die really says, how to compute it without going back to the underlying space , and how far a random variable can stray from its mean. The answers are the formula for , the variance, and three inequalities, Markov's, Chebyshev's and Jensen's, which turn a mean and a variance into guarantees about probabilities.
Expectation as an integral
Let be a random variable on a probability space . Its expectation, also called its mean or expected value, is the Lebesgue integral of against :
For a simple random variable , the integral of "The Lebesgue integral" is the sum : each value is weighted by the probability of the event on which it is taken. A fair die is the model case. Take with mass on each face and . Then
The number can be read in two ways, and both are worth keeping. The first is the long-run average: roll the die many times and the average of the results settles near . A later lesson of this track proves this as the law of large numbers; here it serves as the intuition. The second reading is a balance point. Put the distribution of on a beam as sand, a pile of mass at each of , and the beam balances on a pivot at . The mean is the centre of mass of the distribution.
Neither reading says that is a likely or even a possible outcome, and a die never shows it. The mean describes where the distribution is centred, not what to expect on a single roll.
The integral of "The Lebesgue integral" does not always give a finite number, and the same care applies here. If , then always exists, possibly as . For a general , split into its positive and negative parts. The expectation is whenever at least one of the two terms is finite, and is integrable when both are, which is the same as . Linearity, monotonicity and the fact that changing on a set of probability zero changes nothing all carry over from the integral, and so does . For a constant, , because the total mass is .
Computing expectations from the distribution
The definition integrates over , but is often out of sight. For a dart thrown at a square it is the square, for an endless sequence of coin tosses it is a set of binary digit sequences, and the point of "Random variables and their distributions" was that the distribution on the real line carries what matters about . The expectation can be computed from the distribution alone. For a measurable function ,
Taking gives the mean from the distribution, and gives the second moment, which is needed below. The proof follows the pattern used for every statement about integrals: indicators, then simple functions, then non-negative functions.
- Indicators. For with a Borel set, equals 1 exactly when , so . This is the definition of the image measure from "Measurable functions".
- Simple functions. A simple is a finite combination of indicators, and both sides of the formula are linear in , so the first stage gives the second.
- Non-negative functions. Choose simple functions , the dyadic staircases of "Measurable functions". Then , and monotone convergence from "Convergence theorems" lets the limit pass inside the integral on both sides, so the formula holds for .
- General functions. Apply the result to and separately and subtract.
Two consequences follow. First, depends on only through its distribution: two random variables with the same distribution, even on different probability spaces, have the same expectation. Second, the integral against is one of the concrete integrals of "The Lebesgue integral", and which one depends on the shape of the distribution:
- A distribution made of atoms only (a discrete one): , a sum over the possible values.
- A distribution with a density : .
- A mixed distribution: the sum for the atoms plus the integral for the density part.
The waiting time at the traffic light of "Random variables and their distributions" is a mixed case. With probability the light is green and ; otherwise is exponential with mean minutes. The distribution is a point mass of size at plus a density part of total mass , so
On average a driver waits minutes, although most drivers wait not at all and the rest wait about two minutes. The same distribution gives , since an exponential with mean has second moment (the case of mean is computed in the section on variance).
The dart board of "The Lebesgue integral" is an example on a continuous space. A dart lands uniformly on the unit square, which has area 1, so probability equals area. The board has concentric rings around the centre of the square with outer radii , , and , scoring , , and points, and the corners score . The score is a simple function, so its expectation is each score times the probability of its ring, which is the ring's area :
A throw scores , , , or , and no throw scores . The number is the long-run average score per throw.
The tail formula
For a non-negative random variable there is a second way to compute the mean, which uses only the probabilities of exceeding each level . The layer-cake formula of "The Lebesgue integral", , applied with and , says
Think of the value of as a stack of thin layers, one for each height between and . The layer at height is present exactly when , which has probability , so the average height of the stack is the sum of these probabilities over all heights. The function is the tail of the distribution. It starts at or a little below and decreases to when is finite, and the mean is the area under it.
For the exponential law with mean , , and is the mean, found with no integration by parts. For the fair die the tail is a staircase: for in with , , a step of width , so
This is the same as before, reached by a different cut. The earlier computation sliced the average into columns, one per value of ; this one slices it into layers, one per level. Using instead of gives the same integral, because the two functions differ at only countably many , the atoms of the distribution. The formula is useful whenever tail probabilities are easier to find than a density, and it prepares the inequalities below, which are statements about tails.
Linearity and the indicator trick
Linearity of the integral gives, for integrable and on the same probability space and any constants and ,
No assumption about how and are related is needed. They can be identical, opposite or tangled together in any way: a sum of two functions on is integrated by integrating each and adding. This is unusual, since most statements about several random variables need a condition on how they interact. The tool that makes linearity useful is the indicator. For an event ,
A random count is a sum of indicators, one for each thing counted, and its mean is the sum of the probabilities, however tangled the things are. Roll a die ten times and let be the number of sixes. Then , and
Here the rolls do not influence each other, but the computation never used that, and the next example shows why this matters. A secretary has letters and addressed envelopes and puts the letters into the envelopes in random order, every arrangement being equally likely. Let be the number of letters that land in their own envelope. Letter is equally likely to land in any of the envelopes, so it lands in its own with probability , and
The events influence each other: if the first letters are in their own envelopes, the last one must be too. The distribution of is complicated, and yet its mean is for three letters and for a hundred. For the six arrangements can be listed: the identity has correct letters, each of the three swaps of two letters has , and the two cyclic shifts have , so the mean is .
Linearity does not extend to products. In general : for the die, , while . The next lesson, "Independence and product measures", shows which extra condition makes the product rule true.
Infinite expectations and expectations that do not exist
A non-negative random variable always has an expectation, but it can be infinite, even when the variable is finite with probability one. The St Petersburg game shows how. A fair coin is tossed until the first head. If the first head comes on toss , which has probability , the prize is : a prize of with probability , of with probability , of with probability , and so on. Every outcome gives a finite prize, yet
Each possible number of tosses adds one unit to the mean. If the game is stopped after at most tosses, with prize when no head has appeared by then, the mean is exactly : for , and a million for a million tosses. Without a cutoff the mean grows past every bound, because the rare huge prizes carry as much weight as the common small ones. No finite amount is a fair average.
A variable that takes both signs has a second way to fail. The Cauchy law has density on the whole line. It is a proper density, with total mass , but
Both and are infinite, so would be , and there is no mean. Symmetry suggests , but symmetry cancels the two infinite halves only after one decides how to cut them, and a different cut gives a different answer; the integral refuses to choose. The practical symptom is that averages of more and more Cauchy values never settle down. This is why the definition asks for before it speaks of the mean of a variable with both signs.
Variance and moments
The mean locates a distribution but says nothing about its spread. A variable that equals with certainty and a fair die have the same mean and little else in common. The usual measure of spread is the average squared distance from the mean. For with and mean , the variance and the standard deviation are
Squaring makes every deviation count positively, so deviations above and below the mean do not cancel, and it keeps the algebra clean. The square root undoes the squaring, so has the same unit as . The variance is an expectation like any other, , and is computed from the distribution. Expanding the square and using linearity gives a shortcut. First,
Now take expectations of each term. The mean is a constant, so and :
For the die, and , so and . For the exponential law with mean , integration by parts twice gives , so and . For the traffic light, and , more than twice the mean, which reflects many zeros and a few long waits.
The variance is zero only for a constant: forces almost surely, by the rule from "The Lebesgue integral" that a non-negative function with integral zero vanishes almost everywhere. Shifting and scaling behave simply. If , then , so and
Adding a constant slides the whole distribution without changing its spread, and multiplying by multiplies the standard deviation by . For with a die, . How variance behaves for a sum of two random variables is the subject of "Independence and product measures".
The numbers are the moments of , and the mean and the second moment are the first two. The random variables with are said to lie in ; for these are the integrable ones. A variable can have a mean and no variance, but on a probability space a finite higher moment always forces the lower ones to be finite. For the reason is the inequality , valid for every real : when the right side is at least , and when we have . Taking expectations gives , where the is , finite because the total mass is . A finite variance therefore guarantees a mean. On the whole line with Lebesgue measure the constant is not integrable, and the implication fails.
Markov's inequality
How much probability can sit far from the mean? For a variable that is never negative, the mean alone already limits it. Markov's inequality says that for and any ,
If the average is and the values are never negative, at most of the probability can lie at or beyond. Picture the sand on the beam, which starts at and extends to the right. Sand beyond sits at least away from the left end, so every unit of it pushes the balance point at least to the right; with too much of it out there, the balance point could not stay at .
The proof is a comparison of two functions. For and ,
holds at every outcome: where the left side is , and elsewhere it is because is not negative. Expectation is monotone and , so , and dividing by finishes the proof.
The inequality uses nothing but the mean, so it has to hold for every distribution with that mean, and it is often far from the truth. For the exponential law with mean and , the true tail is , while Markov gives , nearly seven times larger. It is not wasteful for every law. The two-point law with mass at and at has mean and , exactly the bound, so no better bound can be had from the mean alone. For the bound is at least and says nothing.
Chebyshev's inequality
Markov's inequality controls one side of a non-negative variable. To control the distance from the mean on both sides, apply it to the non-negative variable , whose mean is the variance, at the level . The event is the same event as , so for and ,
This is Chebyshev's inequality. Whatever the distribution, at most of the probability lies two standard deviations or more from the mean, at most three or more, and at most four or more. The standard deviation becomes a ruler for rare events, and the only ingredients are the mean and the variance.
For the die, and . The event consists of the faces and , so its probability is , while Chebyshev, with , gives . For the exponential law with mean and standard deviation , take : the event is , because is impossible, with probability against the bound . Even for the normal law the bound is generous, since two standard deviations leave about in both tails together.
Is the bound as good as it can be when only the mean and variance are known? It is. For , take the three-point law with masses , and at , and . By symmetry its mean is . Its variance is , and , exactly the bound. For each some law with that mean and variance reaches it, so no smaller number can replace in a statement that uses only and .
The figure compares the true tail with the bound. Choose a law and a bound, then move the slider: for Markov, where the plot shows against , or for Chebyshev, where it shows against . The solid curve always stays below the dashed one. With the exponential law and Markov at the default , the readouts show against , a ratio of about ; switching to Chebyshev at gives against , a ratio of about . The die draws a staircase with a jump at every face. The last law changes with the slider: it is the two-point law for Markov or the three-point law for Chebyshev that attains the bound at the marked value, where the solid curve touches the dashed one and the ratio is exactly .
- μ
- 1.000
- σ
- 1.000
- True probability
- 0.0498
- Bound
- 0.3333
- Bound / true
- 6.70
The solid curve is ℙ(X ≥ a), the dashed one 𝔼X / a, capped at 1. Move a: the bound always lies above the curve, and far from a = 𝔼X it is loose.
Jensen's inequality
The last inequality compares the average of a function with the function of the average. A function is convex if every chord between two points of its graph lies above the graph:
Read this as an expectation. Let equal with probability and with probability . Then is and the right side is , so the statement is . Jensen's inequality says the same for every integrable random variable with integrable and every convex . In a picture: the average of points on a convex curve lies above the curve, at the average position.
The proof for a general replaces the chord by a tangent. A convex function lies above its tangent lines, so at there is a slope (at a corner of the graph, any slope between the left and right slopes) with
Put and take expectations. The term vanishes, and what remains is Jensen's inequality:
Three consequences come back constantly. With the inequality reads , which says that the variance is not negative; the variance is exactly the gap in Jensen's inequality for . For the die, , and the gap is . With it gives . With it gives : for the die, , far above .
For a concave function the inequality turns around, and it is a warning against a common mistake: in general . For the concave and a die, , below . The two agree only for affine , which is linearity again.
Summary
- The expectation is the Lebesgue integral under a probability measure: the long-run average, and the balance point of the distribution. It exists for (possibly infinite) and for integrable .
- computes it from the distribution: a sum for atoms, for a density, both for a mixed law. For , .
- Expectation is linear with no condition on and , and , so counts are averaged by adding probabilities. The mean can be infinite (St Petersburg) or not exist at all (Cauchy).
- measures spread, , and a finite second moment implies a finite first moment.
- Markov: . Chebyshev: , sharp for a three-point law. Jensen: for convex .