Mathematics · Article
Expectation, variance and covariance
Calculate averages and spread from probability laws, keep dependence in product and variance calculations, and check when moments exist. Derive conditional averaging, total variance, least-square prediction, tail identities and moment bounds without hiding heavy-tail failures.
Back to MathematicsAfter reading, you can
- Calculate expectations from a law and distinguish finite, infinite and undefined signed expectations.
- Use expectations of functions and linearity without unnecessary transformed distributions or independence assumptions.
- Calculate variance, standard deviation, covariance and correlation with their moment and unit conditions.
- Retain covariance cross terms in sums and distinguish uncorrelated variables from independent variables.
- Derive total expectation, total variance and conditional-mean least-square prediction.
- Use tail identities, Jensen, Markov and Chebyshev with appropriate hypotheses and interpretations.
- Recognize heavy-tail cases where symmetry, finite observations or a finite mean do not supply the moments needed by a formula.
An average belongs to a specified probability law
Expectation averages a numerical recording using its probability law. In general E[X]=∫ΩX dP=∫ℝxμ_X(dx), when the integral is defined. For a discrete law, this becomesΣₓx p_X(x); for a law with density, it becomes∫ℝx f_X(x)dx. A mixed or singular law still has an expectation when the general integral permits it. A density is not required.
Consider a hypothetical loss X with values 0,4,10 and probabilities 3/5,3/10,1/10. Its expectation is 0×3/5+4×3/10+10×1/10=11/5=2.2. The most likely value is 0, and the median is 0, while 2.2 is not a possible recorded loss. Mean, mode, median and possible value are different concepts. The expectation is a weighted summary, not a claim about the single outcome most likely to occur.
The weights must come from the law of the selected recording. Averaging the three labels 0,4,10 equally would give 14/3 and would describe a different model. Likewise, a sample average from observed data is an empirical summary, while the population expectation belongs to the model or target law. Their relationship requires assumptions about how observations were obtained.
Expectation carries the variable’s units. A mean loss has loss units; a mean time has time units. Dimensionless probabilities serve as weights. This simple check helps identify formulas that add incompatible quantities or confuse a probability with a numerical measurement.
For independent identically distributed integrable observations, later laws of large numbers explain a precise connection between sample averages and expectation. That theorem is not the definition of expectation, and its hypotheses matter. Some laws in this lesson have no finite expectation at all. Before manipulating an average algebraically, establish which kind of expectation exists.
Infinite can be a defined answer
For X≥0, its expectation is always defined as a nonnegative extended value in[0,∞]. It may be finite or+∞. One way to construct it is to approximate X from below by bounded nonnegative simple recordings and take the increasing limit of their averages. No cancellation is involved, so the limiting value remains meaningful even when it grows without bound.
For a general signed variable, the condition E|X|<∞ is called integrability. It guarantees a finite expectation and permits the ordinary signed algebra used below. A variable is square-integrable, written X∈L², when E[X²]<∞. This implies integrability, for example from 2|X|≤1+X². Square-integrability is the convenient sufficient condition for finite variances and the covariance identities in this lesson.
A finite value at every individual outcome does not ensure a finite expectation. Let a positive-integer law have p(k)=1/[k(k+1)] for k≥1. Its total mass is one because 1/[k(k+1)]=1/k−1/(k+1) telescopes. Its expectation isΣ_{k≥1}1/(k+1), which diverges. Every draw is a finite integer, but rare large values make the nonnegative extended mean infinite.
Finite samples from that law always have finite arithmetic averages. Their finiteness does not prove that the underlying mean is finite or that an ordinary finite-mean limit theorem applies. Inspect the tail and the moment integral rather than inferring existence from a short observed record.
Keep the vocabulary precise. A nonnegative expectation of+∞ is defined as an extended value. It is not a finite mean, and it is not the undefined difference of two infinite signed contributions. The next section explains that separate failure. Software and reports should distinguish these statuses rather than returning the same vague error or a fabricated finite number.
Symmetry cannot cancel two infinite halves
Write X⁺=max(X,0) and X⁻=max(−X,0), so X=X⁺−X⁻ and|X|=X⁺+X⁻. Both parts are nonnegative and have extended expectations. If at least one of E[X⁺],E[X⁻] is finite, their difference defines the signed extended expectation. If both are infinite, E[X] is undefined:∞−∞ has no assigned value. Integrability makes both finite.
For the standard Cauchy density f(x)=1/[π(1+x²)], the positive first-moment integral through R is∫₀ᴿx f(x)dx=log(1+R²)/(2π), which diverges as R grows. The negative absolute half has the same divergence. Therefore the signed expectation is undefined. The density is symmetric and its median is zero, but neither fact supplies a mean.
Symmetric truncations give∫_{−R}ᴿx f(x)dx=0 for every R. That limiting operation is a Cauchy principal value, not the probability expectation. For asymmetric truncations,∫_{−R}^{2 R}x f(x)dx tends to log 2/π instead. Different cancellations can produce different limits because the absolute first moment is infinite.
The same issue can occur in signed series. If positive and negative expected contributions each diverge, a rearrangement or pairing does not turn them into an integrable sum. State the positive and negative parts, or establish absolute integrability before rearranging. Numerical symmetry, a finite cutoff and a balanced plotting window can hide this failure.
Throughout the finite-moment calculations, a mean means a finite expectation unless an extended value is explicitly stated. A law with an undefined mean does not acquire a variance by substituting its median or principal value into a centered formula. You may study other summaries, but name them correctly and preserve the missing-moment limitation.
Average the function directly against the original law
For a measurable function g, E[g(X)]=∫g(x)μ_X(dx) whenever the expectation is defined. This is often called the law of the unconscious statistician, or LOTUS. For discrete X, sum g(x)p_X(x); for a density, integrate g(x)f_X(x). Nonnegative g or E|g(X)|<∞ are useful sufficient conditions. You do not need to derive a separate distribution for g(X) first.
The identity begins with indicator functions: E[1_{X∈A}]=P(X∈A)=μ_X(A). Finite linear combinations give it for simple functions. Increasing nonnegative approximations extend it to nonnegative functions, and positive and negative parts give the integrable signed case. This explains why the same method works for mixed and singular laws, not only for familiar density formulas.
Let X have density 2 x on(0,1), and define G=1+3 X². Direct integration gives E[X²]=∫₀¹2 x³dx=1/2 and E[X⁴]=∫₀¹2 x⁵dx=1/3. Hence E[G]=1+3/2=5/2. Later we can obtain its variance from these same moments without constructing G’s transformed density.
A nonlinear function generally does not commute with averaging. Here E[X]=2/3, so 1+3(E[X])²=7/3, different from E[1+3 X²]=5/2. The function must be averaged over the law, rather than evaluated only at its mean. Jensen’s inequality later gives a systematic direction under convexity or concavity.
W2: g(X)=1+3X squared, density 2x
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Normalized input density | 2x on (0,1) |
| g(x) | a + b x + c x squared; coefficients 1, 0, 3 |
| E[X] | 2/3 |
| E[X squared] | 1/2 |
| E[X to the fourth] | 1/3 |
| E[g(X)] | 5/2 |
| g(E[X]) | 7/3 |
| Var(g(X)) | 3/4 |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown. Both displayed densities normalize on their declared bounded support; all polynomial moments here are finite. The variance row uses E[g(X) squared] minus the square of E[g(X)].
For a mixed law, include every component: an atom contributes g(a) times its mass and a density component contributes its weighted integral. Omitting atoms because the continuous curve looks convenient changes the expectation. For singular laws, use their measure or an established construction; differentiating a CDF need not provide a complete density to integrate.
Add finite expectations even when variables depend
If X₁,…,Xₙ are integrable and a₁,…,aₙ are real constants, E[ΣᵢaᵢXᵢ]=ΣᵢaᵢE[Xᵢ]. This is linearity of the integral. Independence is not needed. Each variable’s expected contribution can be added even when their outcomes are constrained or share a common influence.
Let X be one with probability 3/10 and zero otherwise, and let Y=1−X. These variables are dependent: one determines the other. Nevertheless, E[2 X+5 Y]=2(3/10)+5(7/10)=41/10. Directly,2 X+5 Y equals 2 with probability 3/10 and 5 with probability 7/10, giving the same mean.
W3: 2X+5(1-X), p=3/10
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Declared dependence | Y=1-X |
| E[X] | 3/10 |
| E[Y] | 7/10 |
| a E[X] + b E[Y] | 41/10 |
| Cov(X,Y) | -21/100 |
| Marginal variance contributions | 609/100 |
| Signed cross contribution | -21/5 |
| Variance of aX+bY | 189/100 |
| Mean condition | Finite linearity does not require independence |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown. Here Cov(X,Y)=E[XY]-E[X]E[Y], and variance is the expectation of the squared deviation from the mean. Every quantity in this finite binary example exists.
The finite integrability conditions prevent undefined cancellation. Writing E[X−X]=E[X]−E[X] is unsafe if E[X] is an extended infinite value, even though the left-hand variable is exactly zero. The right side would be∞−∞. For integrable X, both sides are finite and linearity applies normally.
Infinite sums require their own justification. Nonnegative partial sums increase, so monotone convergence allows E[ΣᵢXᵢ]=ΣᵢE[Xᵢ] as an extended equality when every Xᵢ≥0. For signed terms, a sufficient condition isΣᵢE|Xᵢ|<∞; this controls the absolute sum and permits interchange. Finite linearity alone does not justify arbitrary infinite rearrangements.
This distinction is useful for counting and repeated measurements. A sum can have an easy mean despite complicated dependence, but its variance requires joint information. Do not carry an independence assumption into a mean calculation when it is unnecessary, or carry mean linearity into a variance calculation where it is generally false.
Products need more than linearity
For independent integrable X and Y, E[XY]=E[X]E[Y]. Independence also gives E|XY|=E|X|E|Y|<∞, so the product is integrable. This factorization uses the product joint law. It does not follow from linearity, and it is not true for arbitrary dependent variables.
For X equal to±1 with equal probability and Y=X, both marginal means are zero. Yet XY=X²=1 always, so E[XY]=1 rather than E[X]E[Y]=0. Knowing the two marginal means is insufficient. The joint construction determines which values are multiplied together.
Even when individual means exist, a product can require additional moment checks. Square-integrability of both variables is a convenient sufficient condition because 2|XY|≤X²+Y². More refined conditions are possible, but a formula containing E[XY] must not silently assume that term is finite or defined.
Conversely, one product equality does not prove independence. A dependent pair can satisfy E[XY]=E[X]E[Y] while disagreeing on other joint events or nonlinear products. Covariance measures this one centered product under finite-moment conditions; it is not a complete description of dependence.
Scientific models often simplify products by assuming independent errors or inputs. Check what is independent, under which conditioning information, and whether the required moments exist. Conditional independence can justify factorization inside a conditional law without implying factorization after mixing groups, as the previous lessons showed.
Turn event counts into sums of indicators
The indicator 1_A equals one on event A and zero otherwise. Its expectation is P(A), because the only nonzero contribution is 1×P(A). Its variance is P(A)(1−P(A)), derived from 1_A²=1_A. Indicators translate event probabilities into numerical moments without requiring a named distribution.
For a finite count N=Σᵢ1_{Aᵢ}, linearity gives E[N]=ΣᵢP(Aᵢ) whether or not the events are independent. If six labelled objects are uniformly permuted among six labelled positions, let Aᵢ be the event that object i lands in its own position. Each has probability 1/6, so the expected number of matches is one. The match events are constrained by the permutation, but that does not affect this mean argument.
Joint events enter the count’s spread. For two indicators, Cov(1_A,1_B)=P(A∩B)−P(A)P(B), once covariance is defined below. The intersection is extra information beyond the two marginals. Positive or negative dependence can change count variation even when the expected count remains the same.
For sampling without replacement, indicators for marked draws have equal marginals but negative pairwise covariance. With four marked items among ten and three ordered draws, each marked indicator has mean 4/10. The count mean is 3×4/10=6/5. Computing its variance must retain the changing joint draw probabilities; treating the three indicators as independent would overstate it.
The indicator method is a useful design habit: define exactly which event each term counts, establish its marginal probability, and use linearity for the mean. Then gather pairwise intersections if a variance is needed. This separates an easy counting expectation from the more demanding dependence calculation.
Variance measures squared distance from a finite mean
For integrable X with finite meanμ=E[X], define Var(X)=E[(X−μ)²], a nonnegative extended value. If X∈L², it is finite. Expanding the square gives Var(X)=E[X²]−μ², since E[X−μ]=0. All terms are finite in the square-integrable case, so the subtraction is justified.
For the loss law 0,4,10 with masses 3/5,3/10,1/10, E[X]=11/5 and E[X²]=16(3/10)+100(1/10)=74/5. Therefore Var(X)=74/5−121/25=249/25=9.96. The standard deviation is√249/5≈3.156, in the original loss units. Squaring the mean and averaging the square are different operations.
W1: loss 0, 4 or 10
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| v1 = 0 (loss units) | mass 3/5 |
| v2 = 4 (loss units) | mass 3/10 |
| v3 = 10 (loss units) | mass 1/10 |
| Mass total | 1 |
| E[X] (loss units) | 11/5 |
| E[X squared] (loss units squared) | 74/5 |
| Var(X) (loss units squared) | 249/25 |
| SD(X) (loss units) | sqrt(249/25) (approx 3.1559) |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown.
A finite mean does not ensure finite variance. Defineζ(s)=Σ_{k≥1}k^{−s} for s>1. The law p(k)=1/[ζ(3)k³] has finite E[X]=ζ(2)/ζ(3), but E[X²]=(1/ζ(3))Σ1/k=∞. Its centered squared expectation is also infinite. This law is integrable but not square-integrable.
Under the convention used here, variance is undefined when there is no finite mean to center around. For a Cauchy variable, the second raw moment is infinite and the signed mean is undefined, so we do not report an ordinary variance or standard deviation. Distinguish that status from an integrable variable whose variance is the well-defined extended value∞.
W12: symmetric cancellation is principal value
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Density and support | 1/[pi(1+x squared)], -infinity < x < +infinity |
| Expectation | undefined; Both positive and negative first-moment parts are +infinity. |
| Positive and negative moment parts | Both +infinity |
| Second moment | +infinity |
| Variance | undefined; There is no finite mean; under this convention variance is undefined. |
| Symmetric principal value | 0; this is not expectation |
| Finite left/right cutoffs | 10 / 10 |
| Positive truncated half (approx) | 0.73452 |
| Negative truncated half magnitude (approx) | 0.73452 |
| Truncated signed integral (approx) | 0 |
| As R grows with fixed multipliers | Limit = log(rightFactor/leftFactor)/pi = 0 (approx) |
| Median | 0; this also does not supply a mean |
The law is normalized and symmetric, but not integrable. No mathematical infinity is emitted as a JSON number. The plotted finite integrals and their principal/asymmetric limits remain separate from the undefined mean and variance. These are unnormalised truncated integrals, not expectations under a conditional truncated law.
Variance is zero exactly when X=μ almost surely. A nonnegative squared deviation can have expectation zero only if it is zero outside a null set. This allows exceptional null outcomes without changing the variance. It also explains why a zero-variance variable cannot supply a nonzero denominator for an ordinary correlation coefficient.
Keep spread units consistent
Variance carries squared units because it averages squared deviations. If X measures seconds, Var(X) is measured in seconds². Standard deviation SD(X)=√Var(X) carries seconds. A variance of 9 seconds² means a standard deviation of 3 seconds, not 9 seconds. The mean and standard deviation can be plotted on the same physical axis, while variance needs its own squared-unit interpretation.
Changing numerical units changes the size of moments in predictable ways. Converting seconds to milliseconds multiplies every value and mean by 1000, standard deviation by 1000 and variance by 1,000,000. A numerical comparison of variances in different units is meaningless until the scales are aligned.
A centered squared distance weights large deviations more heavily than small ones. It is a particular spread summary, not the probability of being far from the mean. Two laws can have the same variance and very different tail probabilities. Moment inequalities later provide guarantees, but do not recover an entire tail from one spread number.
Some laws have no finite standard deviation, and a finite sample does not change that property of the law. A plotted range or a finite table of observed values cannot establish a population second moment. State whether the moment is a model calculation, an estimate from data or a bound based on additional information.
The term error bar also needs an identified quantity. A standard deviation of individual readings, a standard error of an estimated mean and a predictive interval are different objects. Their interpretation depends on replication, dependence, sample size and modeling assumptions. Naming the units and the target is the first step toward making such displays scientifically readable.
Offsets move the mean; scales change spread
For integrable X and real constants a,b, linearity gives E[aX+b]=aE[X]+b. For square-integrable X, subtract that mean to get(aX+b)−E[aX+b]=a(X−E[X]). Squaring and averaging gives Var(aX+b)=a²Var(X), so SD(aX+b)=|a|SD(X). The offset disappears from deviations, while a negative scale reverses direction but cannot make variance negative.
Let Celsius temperature C have mean 20 and variance 4 in degree-Celsius units squared. Fahrenheit temperature is F=9 C/5+32. Its mean is 68°F, variance(81/25)×4=324/25=12.96°F² and standard deviation 18/5=3.6°F. The 32-degree offset changes the location but not the spread.
W4: Celsius to Fahrenheit
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Input mean (Celsius degrees) | 20 |
| Input variance (Celsius degrees squared) | 4 |
| Affine conversion | output = 9/5 input + 32 |
| Output mean (Fahrenheit degrees) | 68 |
| Output variance (Fahrenheit degrees squared) | 324/25 |
| Output SD (Fahrenheit degrees) | 18/5 |
| Cov(input,output) (Celsius degrees times Fahrenheit degrees) | 36/5 |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown. An affine offset changes the mean; variance uses the square of the scale and SD its absolute value.
For the dependent binary pair X and Y=1−X with P(X=1)=3/10, the weighted value 2 X+5 Y equals 5−3 X. Its mean is 41/10 and its variance is 9×(3/10)(7/10)=189/100. This direct affine calculation will provide a check on the covariance expansion below.
A standardized variable Z=(X−μ)/σ has mean zero and variance one whenμ is finite and 0<σ²<∞. It is dimensionless. Standardization changes location and scale but does not turn an arbitrary law into a normal distribution or remove its dependence with other variables. Ifσ=0 or is not finite, this ordinary standardization is unavailable.
These rules help separate representation changes from scientific changes. A unit conversion should preserve probabilities of corresponding physical events while rescaling moments consistently. Changing the population or the observation mechanism can instead change the law itself. Do not treat a change in numerical variance caused only by units as evidence of a different physical variability.
Covariance averages a centered joint product
For X,Y∈L², define Cov(X,Y)=E[(X−E[X])(Y−E[Y])]. Expanding gives E[XY]−E[X]E[Y]. Square-integrability ensures the relevant products are integrable;2|XY|≤X²+Y² is one sufficient bound. More general definitions can use other integrability conditions, but the L² scope keeps the ordinary identities here finite and unambiguous.
Positive covariance means that above-mean and below-mean deviations tend to align in this weighted-product sense. Negative covariance means the centered products average negatively. A covariance of zero says that this one product average vanishes; it does not rule out every other form of dependence.
For indicators, the definition reduces to Cov(1_A,1_B)=P(A∩B)−P(A)P(B). The term is exactly the difference between the actual joint probability and its independent product. In the dependent binary pair X and Y=1−X with P(X=1)=3/10, XY=0, so Cov(X,Y)=−(3/10)(7/10)=−21/100.
Covariance is symmetric and bilinear under the finite-moment conditions. In particular, Cov(aX+b,cY+d)=ac Cov(X,Y); offsets disappear because of centering. For Celsius and Fahrenheit in the preceding example, Cov(C,F)=(9/5)Var(C)=36/5, with units°C·°F. Scaling only one variable negatively reverses the covariance sign.
For a vector of square-integrable variables, the covariance matrixΣ has entriesΣᵢⱼ=Cov(Xᵢ,Xⱼ). It is symmetric, and every real vector a satisfies aᵀΣa=Var(ΣᵢaᵢXᵢ)≥0, so it is positive semidefinite. This is a consistency requirement on proposed moment data. Pairwise bounds are useful but do not by themselves establish validity of every larger covariance matrix.
Normalize covariance only when both spreads permit it
Let U=X−E[X] and V=Y−E[Y]. The nonnegative quantity E[(U−tV)²] is a quadratic in t. If E[V²]>0, minimizing that quadratic gives(E[UV])²≤E[U²]E[V²]. If E[V²]=0, V=0 almost surely and the same inequality is immediate. Thus|Cov(X,Y)|≤SD(X)SD(Y), the centered Cauchy–Schwarz inequality.
When both variances are finite and strictly positive, the Pearson correlation isρ=Cov(X,Y)/[SD(X)SD(Y)]. It is dimensionless and lies in[−1,1]. If either variance is zero, the ordinary coefficient is undefined because its denominator is zero. An undefined or infinite required moment also prevents this finite-moment formula from being used.
For variances 9 and 16 and covariance 6, the standard deviations are 3 and 4, soρ=6/12=1/2. The covariance is admissible because|6|≤12. Proposed variances 4 and 9 with covariance 7 would fail the bound|Cov|≤6 and cannot describe a pair of real L² variables.
Under the positive-variance conditions,|ρ|=1 means that the centered variables are nonzero constant multiples of one another almost surely. This follows from equality in the quadratic bound: an appropriate U−tV has squared expectation zero. A deterministic affine relationship therefore gives perfect positive or negative correlation according to its slope.
Correlation measures linear association under the specified law. It does not identify a cause, and a large magnitude does not validate a sampling or measurement model. A small magnitude can coexist with strong nonlinear dependence. Examine the joint pattern and the scientific process rather than treating one coefficient as a complete relationship description.
Conditional expectation is a function of the available information
For integrable X and a real recording Y, a conditional expectation m(Y)=E[X|Y] is an integrable, Y-measurable random variable that preserves averages on every event determined by Y:∫_A m(Y)dP=∫_A XdP for A∈σ(Y). Hereσ(Y) is the event collection generated by observing Y. The conditional mean is therefore a new numerical recording, not generally one constant.
In a discrete model, at a value y with P(Y=y)>0, calculate m(y)=ΣₓxP(X=x|Y=y). It is the mean inside that conditional law. If Y labels groups, m(Y) assigns each outcome its group mean. A null group does not have an event-ratio conditional to evaluate and does not affect unconditional averages.
For a suitable continuous joint-density model, a conditional-density version gives m(y)=∫x f_{X|Y}(x|y)dx where the conditional integral is appropriate. Exact continuous observations do not acquire positive point probability; the construction is a conditional-law version, with almost-everywhere qualifications. More general joint laws can use the defining event-integral property without a density.
Conditional expectations are unique up to almost-sure equality. Versions can differ on null information states without changing the defining integrals. The event-integral definition and the finite table calculation are consistent: summing the table’s group means over a Y-defined event reproduces the original X average over that event.
The notation E[X|Y] describes information, not a causal intervention. It predicts an average under the stated joint law. Changing the system so that Y is forced to a chosen value can be another scientific question with different assumptions. The distinction between observation and intervention remains important even when a conditional mean is easy to calculate.
Average the conditional averages with their probabilities
Taking A=Ω in the defining conditional-expectation property gives E[E[X|Y]]=E[X] for integrable X. For nonnegative X the analogous extended identity also holds. This is the law of total expectation: conditional means can vary with the observed information, but averaging them under that information’s actual law recovers the original mean.
For a finite or countable partition with positive cell probabilities, E[X]=ΣᵢP(Bᵢ)E[X|Bᵢ], under the corresponding integrability or nonnegativity conditions. Null cells contribute no mass and are omitted. The weighting is essential. Conditional means 10 and 20 with group probabilities 3/5 and 2/5 give overall mean 14, not the unweighted average 15.
Suppose a group label S equals 1 with probability 1/4. Conditional on S=0, a recording has mean 4; conditional on S=1, mean 12. Its overall mean is(3/4)4+(1/4)12=6. These mean data suffice for total expectation, although they do not determine the complete conditional distributions or the overall variance.
A nested-information version is called the tower property. If one event collection𝒢 is contained in a finer collectionℋ, then E[E[X|ℋ]|𝒢]=E[X|𝒢] for integrable X. The finer conditional mean preserves X’s integrals on every𝒢-event, so conditioning it down to𝒢 gives the coarser conditional mean. The containment of information is part of the statement; arbitrary nonnested recordings do not justify this simplification.
These identities do not authorize cancellation of undefined signed expectations. If positive and negative contributions both diverge, first establish a meaningful conditional and unconditional expectation. Likewise, a change in population weights changes the mean being calculated. Total expectation is an accounting identity within a specified joint law, not a way to bypass missing moments or mismatched populations.
Separate within-group noise from between-group variation
For X∈L², the law of total variance is Var(X)=E[Var(X|Y)]+Var(E[X|Y]). The first term averages variation remaining inside information groups; the second measures how their means vary. Both terms are nonnegative. The conditional convexity inequality m(Y)²≤E[X²|Y] shows that m=E[X|Y] is also square-integrable, so these finite-moment expressions are legitimate.
To derive the identity, write X−E[X]=(X−m)+(m−E[X]). The cross term averages to zero because E[X−m|Y]=0 and m−E[X] is determined by Y. Squaring and averaging leaves E[(X−m)²]+E[(m−E[X])²]. These are exactly the two terms in the formula.
In the group example, S=1 with probability 1/4; conditional means are 4 and 12 and conditional variances 1 and 9. The within-group contribution is(3/4)1+(1/4)9=3. The group means vary with variance(12−4)²(1/4)(3/4)=12. The total variance is 15. Reporting only the average conditional variance would omit the larger between-group contribution.
W7: within 3, between 12, total 15
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Group 0 | probability 3/4, conditional mean 4, conditional variance 1 |
| Group 1 | probability 1/4, conditional mean 12, conditional variance 9 |
| E[X] (outcome units) | 6 |
| E[Var(X|S)] | 3 |
| Var(E[X|S]) | 12 |
| Total variance (outcome units squared) | 15 |
| Squared-error risk of conditional mean | 3 |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown. The finite positive-mass groups have finite conditional second moments. Null groups contribute zero. The conditional mean minimizes squared-error risk under these L2 conditions.
Now let a random trial count N equal 1 with probability 1/3 and 7 with probability 2/3. Its mean is 5 and variance 8. Given N=n, let X count successes in n independent pass/fail trials with pass probability 2/5, with the trial sequence independent of N. Then E[X|N]=(2/5)N and Var(X|N)=(6/25)N. Total expectation gives E[X]=2, while total variance gives(6/25)5+(4/25)8=62/25.
The second example includes randomness in how many trials occur. Substituting E[N] into one conditional variance would miss it. If the trial count instead depends on the trial outcomes through a stopping rule, check the conditional law again; the displayed conditional formulas are not automatically preserved. Keep the random-count mechanism and independence assumptions explicit.
W8: N is 1 or 7, p=2/5
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Assumptions | Given N=n, X is Binomial(n,p); the Bernoulli trial sequence is independent of N |
| E[N] | 5 |
| Var(N) | 8 |
| p | 2/5 |
| E[X] = p E[N] | 2 |
| E[Var(X|N)] = p(1-p)E[N] | 6/5 |
| Var(E[X|N]) = p squared Var(N) | 32/25 |
| Total variance of X | 62/25 |
| Exact mixture mass total | 1 |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown.
The conditional mean minimizes expected squared error
Let X∈L², m=E[X|Y], and let h(Y) be any square-integrable predictor using only Y. Decompose X−h(Y)=(X−m)+(m−h(Y)). The cross product has expectation zero: condition on Y, factor out the Y-measurable term and use E[X−m|Y]=0. Integrability of the products follows from the L² conditions.
Therefore E[(X−h(Y))²]=E[Var(X|Y)]+E[(m−h(Y))²]. The second term is nonnegative and becomes zero for h(Y)=m. The conditional mean minimizes expected squared prediction error among such Y-based predictors, uniquely up to almost-sure equality.
In the group example, using each group’s mean gives mean squared error 3, the within-group term. Using the overall mean 6 for every case gives error 15, the total variance. Knowing the group label permits an improvement of 12, exactly the between-group term. This is a prediction calculation in the model, not proof that the group label causes a change in X.
The optimality is specific to squared error and the available information. Another loss function can favor a different summary, such as a conditional median for absolute error under suitable conditions. A predictor restricted to an additional model class can also fail to equal the full conditional mean. State the loss, information and admissible predictors before calling one prediction best.
Expected performance and observed performance are different quantities. Estimating a conditional mean from finite data introduces uncertainty, overfitting and possible model misspecification. The identity establishes the population target under a given joint law; it does not guarantee that a fitted algorithm has achieved it on new cases.
Read moments from the probability of exceeding thresholds
For a nonnegative integer-valued N, the pointwise identity N=Σ_{k≥1}1_{N≥k} gives E[N]=Σ_{k≥1}P(N≥k)=Σ_{k≥0}P(N>k). Nonnegative partial sums increase, so monotone convergence justifies averaging even if the answer is infinite. There is no independence assumption among these nested indicators.
Likewise N²=Σ_{k=1}ᴺ(2 k−1), so E[N²]=Σ_{k≥1}(2 k−1)P(N≥k). If P(N≥k)=(1/3)^{k−1} for k≥1, N is at least one. Its mean is 3/2 and second moment 3, giving variance 3/4. Shifting the tail exponent without shifting the support changes the law.
For any nonnegative real X, X=∫₀∞1_{X>t}dt pointwise, hence E[X]=∫₀∞P(X>t)dt by nonnegative integration. More generally E[Xʳ]=r∫₀∞t^{r−1}P(X>t)dt for r>0, as an extended identity. These formulas show directly why slowly decaying tails can make moments diverge.
For signed X, use positive and negative tails separately. Its positive-part expectation is∫₀∞P(X>t)dt and its negative-part expectation is∫₀∞P(X<−t)dt. Subtract only when that difference is defined. Symmetric infinite tails do not create a finite mean by cancellation.
A finite tail plot or truncated sum should report what is omitted. For a geometric tail an exact remainder can be calculated; for another law it may need a proved bound. A partial sum is a lower bound for a nonnegative expectation, not automatically its full value. Numerical convergence over a short range is not evidence that a heavy-tail integral is finite.
W9: trial count, tail ratio 1/3
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Support and convention | N>=1, P(N>=j)=q^(j-1) |
| First-moment tail partial sum | 29524/19683 |
| Exact first remainder | 1/39366 |
| Second-moment weighted-tail partial sum | 59038/19683 |
| Exact second remainder | 11/19683 |
| E[N] or E[X] | 3/2 |
| Second moment | 3 |
| Variance convention | 3/4 |
| Cutoff K | 10 |
For nonnegative integer N, E[N]=sum P(N>=j), and E[N squared]=sum (2j-1)P(N>=j), j>=1, as extended nonnegative equalities. A signed expectation needs its positive and negative parts separately. Symbolic infinite-series constants are labelled; finite drawing values are not substituted for the full moments. Connecting lines guide the eye between the displayed integer tail indices.
Nonlinear transformations need a direction, not a slogan
For a convex functionφ, φ((1−t)x+ty)≤(1−t)φ(x)+tφ(y) for 0≤t≤1. Jensen’s inequality extends this to averaging:φ(E[X])≤E[φ(X)] under appropriate expectation conditions. A clean finite scope is integrable X andφ(X), withφ finite and convex on an interval containing the values. For concaveφ the inequality reverses.
At an interior meanμ, a supporting affine line satisfiesφ(x)≥φ(μ)+c(x−μ). Averaging removes the centered linear term and proves Jensen. If the mean is an endpoint of the interval containing X, one-sidedness forces X to equal that endpoint almost surely, giving the boundary case directly. Extended versions also permit an infinite upper expectation when the relevant integrals are well-defined; do not subtract two infinities in that argument.
Let X be equally likely to be 2 or 8. Then E[X]=5. The convex square gives E[X²]=(4+64)/2=34>25=(E[X])². The concave logarithm gives E[log X]=(log 2+log 8)/2=log 4<log 5=log(E[X]). Averaging does not increase every nonlinear function in the same direction.
Strict convexity and a genuinely nonconstant integrable variable yield strict inequality in the finite setting, while an affine function commutes with averaging. Conditional Jensen applies the same principle inside a conditional law. In particular,(E[X|Y])²≤E[X²|Y] for X∈L², the bound used in the total-variance argument.
Before applying Jensen, check the function’s domain, curvature and integrability. A logarithm needs positive inputs; a square root has a different concavity direction from a square; a reciprocal needs its domain specified. An average of transformed data and a transformation of their average are different scientific summaries even when both are easy to compute.
W10: log of the mean versus mean log
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Shape and direction | Concave log: E[phi(X)] <= phi(E[X]) |
| E[X] | 5 |
| E[phi(X)] | 1/2 log(2) + 1/2 log(8) (approx 1.3863) |
| phi(E[X]) | log(5) (approx 1.6094) |
| Jensen gap, labelled numerical approximation | 0.22314 |
| Support/domain condition | All positive-mass support values lie in the declared domain. Finite support makes these transformed expectations integrable. |
| Approximation qualification | A numerically tiny gap may round to zero; exact equality is decided separately from the support, and the square gap is the exact variance. |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown.
Moment bounds are guarantees, not reconstructed tails
For nonnegative Z with finite expectation and t>0, Z≥t 1_{Z≥t}. Averaging gives Markov’s inequality P(Z≥t)≤E[Z]/t. A negative-valued variable does not satisfy the required pointwise comparison. If the bound exceeds one, cap it at one; the resulting guarantee may be uninformative without being false.
For X∈L² with meanμ, apply Markov to Z=(X−μ)² at threshold t². Chebyshev’s inequality is P(|X−μ|≥t)≤Var(X)/t² for t>0. It uses only the first two moments and assumes no normal shape or independence. The complement is the strict inside event|X−μ|<t.
If E[X]=10 and Var(X)=9, the probability of distance at least 6 from the mean is at most 1/4. The bound can be sharp: masses 1/8 at 4,3/4 at 10 and 1/8 at 16 have mean 10, variance 9 and exactly 1/4 outside that distance. A different law with the same moments can have a smaller tail, so equality should not be assumed.
W11: a law attaining the one-quarter bound
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Stipulated mean | 10 |
| Stipulated finite variance | 9 |
| Positive threshold t | 6 |
| Raw variance/t squared | 1/4 |
| Outside upper bound, capped at 1 | 1/4 |
| Strict-inside lower bound | 3/4 |
| Actual outside probability | 1/4 |
| Events | Outside: |X-mu| >= t; complementary inside: |X-mu| < t |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown. The threshold is positive. A bound above one is capped at one; it is not clipped into a claimed actual tail probability.
A nonexistent or infinite variance cannot supply a useful finite Chebyshev bound. A sample variance cannot simply replace a population variance without accounting for estimation uncertainty and sampling assumptions. When the full law is known, calculate the actual event probability as well; a moment bound is deliberately less specific.
Expectation, variance and covariance connect probability laws to prediction, uncertainty budgets and experimental design. Means add under integrability, spread depends on joint structure, and nonlinear summaries and tail guarantees have distinct conditions. The next lesson collects common distribution models; the following limit-law lesson studies repeated averages. Preserve the moment-existence, dependence and unit checks before applying those more specialized tools.
Explore expectation, spread and moment conditions
Choose a stipulated law or moment model. Exact fractions, units, signed covariance contributions and required assumptions stay visible. A defined infinite nonnegative expectation, an undefined signed mean and a finite truncated integral have different meanings.
Expectation and squared spread
W1: loss 0, 4 or 10
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| v1 = 0 (loss units) | mass 3/5 |
| v2 = 4 (loss units) | mass 3/10 |
| v3 = 10 (loss units) | mass 1/10 |
| Mass total | 1 |
| E[X] (loss units) | 11/5 |
| E[X squared] (loss units squared) | 74/5 |
| Var(X) (loss units squared) | 249/25 |
| SD(X) (loss units) | sqrt(249/25) (approx 3.1559) |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown.
Average a nonlinear recording
W2: g(X)=1+3X squared, density 2x
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Normalized input density | 2x on (0,1) |
| g(x) | a + b x + c x squared; coefficients 1, 0, 3 |
| E[X] | 2/3 |
| E[X squared] | 1/2 |
| E[X to the fourth] | 1/3 |
| E[g(X)] | 5/2 |
| g(E[X]) | 7/3 |
| Var(g(X)) | 3/4 |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown. Both displayed densities normalize on their declared bounded support; all polynomial moments here are finite. The variance row uses E[g(X) squared] minus the square of E[g(X)].
Linearity under dependence
W3: 2X+5(1-X), p=3/10
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Declared dependence | Y=1-X |
| E[X] | 3/10 |
| E[Y] | 7/10 |
| a E[X] + b E[Y] | 41/10 |
| Cov(X,Y) | -21/100 |
| Marginal variance contributions | 609/100 |
| Signed cross contribution | -21/5 |
| Variance of aX+bY | 189/100 |
| Mean condition | Finite linearity does not require independence |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown. Here Cov(X,Y)=E[XY]-E[X]E[Y], and variance is the expectation of the squared deviation from the mean. Every quantity in this finite binary example exists.
Change units, retain the squared scale
W4: Celsius to Fahrenheit
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Input mean (Celsius degrees) | 20 |
| Input variance (Celsius degrees squared) | 4 |
| Affine conversion | output = 9/5 input + 32 |
| Output mean (Fahrenheit degrees) | 68 |
| Output variance (Fahrenheit degrees squared) | 324/25 |
| Output SD (Fahrenheit degrees) | 18/5 |
| Cov(input,output) (Celsius degrees times Fahrenheit degrees) | 36/5 |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown. An affine offset changes the mean; variance uses the square of the scale and SD its absolute value.
Covariance and weighted variance
W5: variance of 2X-Y
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Var(X) (common units squared) | 9 |
| Var(Y) (common units squared) | 16 |
| Cov(X,Y) (common units squared) | 6 |
| PSD condition | Cov squared <= Var(X) Var(Y) |
| Correlation | 1/2 |
| a squared Var(X) | 36 |
| b squared Var(Y) | 16 |
| 2ab Cov(X,Y), signed | -24 |
| Var(aX+bY) | 28 |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown. X and Y are stipulated L2. The PSD condition is checked exactly, and a zero SD holds correlation only rather than inventing a coefficient.
Zero covariance and nonlinear dependence
W6: X in {-1,0,1}, Y=X squared
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Law of X | Equal masses at -r, 0, r |
| Relation | Y=X squared |
| E[X] and E[XY] | 0 by odd symmetry |
| E[Y] = E[X squared] | 2/3 |
| Var(X) | 2/3 |
| Var(Y) | 2/9 |
| Cov(X,Y) | 0 |
| Correlation | 0 |
| Dependence condition | Nonconstant Y is determined by X; zero covariance does not imply independence |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown.
Within-group and between-group variation
W7: within 3, between 12, total 15
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Group 0 | probability 3/4, conditional mean 4, conditional variance 1 |
| Group 1 | probability 1/4, conditional mean 12, conditional variance 9 |
| E[X] (outcome units) | 6 |
| E[Var(X|S)] | 3 |
| Var(E[X|S]) | 12 |
| Total variance (outcome units squared) | 15 |
| Squared-error risk of conditional mean | 3 |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown. The finite positive-mass groups have finite conditional second moments. Null groups contribute zero. The conditional mean minimizes squared-error risk under these L2 conditions.
A random number of independent trials
W8: N is 1 or 7, p=2/5
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Assumptions | Given N=n, X is Binomial(n,p); the Bernoulli trial sequence is independent of N |
| E[N] | 5 |
| Var(N) | 8 |
| p | 2/5 |
| E[X] = p E[N] | 2 |
| E[Var(X|N)] = p(1-p)E[N] | 6/5 |
| Var(E[X|N]) = p squared Var(N) | 32/25 |
| Total variance of X | 62/25 |
| Exact mixture mass total | 1 |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown.
Moments from nonnegative tails
W9: trial count, tail ratio 1/3
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Support and convention | N>=1, P(N>=j)=q^(j-1) |
| First-moment tail partial sum | 29524/19683 |
| Exact first remainder | 1/39366 |
| Second-moment weighted-tail partial sum | 59038/19683 |
| Exact second remainder | 11/19683 |
| E[N] or E[X] | 3/2 |
| Second moment | 3 |
| Variance convention | 3/4 |
| Cutoff K | 10 |
For nonnegative integer N, E[N]=sum P(N>=j), and E[N squared]=sum (2j-1)P(N>=j), j>=1, as extended nonnegative equalities. A signed expectation needs its positive and negative parts separately. Symbolic infinite-series constants are labelled; finite drawing values are not substituted for the full moments. Connecting lines guide the eye between the displayed integer tail indices.
Convex and concave averaging
W10: log of the mean versus mean log
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Shape and direction | Concave log: E[phi(X)] <= phi(E[X]) |
| E[X] | 5 |
| E[phi(X)] | 1/2 log(2) + 1/2 log(8) (approx 1.3863) |
| phi(E[X]) | log(5) (approx 1.6094) |
| Jensen gap, labelled numerical approximation | 0.22314 |
| Support/domain condition | All positive-mass support values lie in the declared domain. Finite support makes these transformed expectations integrable. |
| Approximation qualification | A numerically tiny gap may round to zero; exact equality is decided separately from the support, and the square gap is the exact variance. |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown.
A bound and an actual tail
W11: a law attaining the one-quarter bound
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Stipulated mean | 10 |
| Stipulated finite variance | 9 |
| Positive threshold t | 6 |
| Raw variance/t squared | 1/4 |
| Outside upper bound, capped at 1 | 1/4 |
| Strict-inside lower bound | 3/4 |
| Actual outside probability | 1/4 |
| Events | Outside: |X-mu| >= t; complementary inside: |X-mu| < t |
Finite algebra here uses integrable means and L2 variables unless an explicit extended or undefined status is shown. The threshold is positive. A bound above one is capped at one; it is not clipped into a claimed actual tail probability.
Undefined mean and principal-value cancellation
W12: symmetric cancellation is principal value
| Quantity or condition | Exact value, symbolic status or labelled approximation |
|---|---|
| Density and support | 1/[pi(1+x squared)], -infinity < x < +infinity |
| Expectation | undefined; Both positive and negative first-moment parts are +infinity. |
| Positive and negative moment parts | Both +infinity |
| Second moment | +infinity |
| Variance | undefined; There is no finite mean; under this convention variance is undefined. |
| Symmetric principal value | 0; this is not expectation |
| Finite left/right cutoffs | 10 / 10 |
| Positive truncated half (approx) | 0.73452 |
| Negative truncated half magnitude (approx) | 0.73452 |
| Truncated signed integral (approx) | 0 |
| As R grows with fixed multipliers | Limit = log(rightFactor/leftFactor)/pi = 0 (approx) |
| Median | 0; this also does not supply a mean |
The law is normalized and symmetric, but not integrable. No mathematical infinity is emitted as a JSON number. The plotted finite integrals and their principal/asymmetric limits remain separate from the undefined mean and variance. These are unnormalised truncated integrals, not expectations under a conditional truncated law.
Worked examples
Calculate the first two moments and spread
A hypothetical loss X is 0,4,10 with probabilities 3/5,3/10,1/10. Find the mean, second moment, variance and standard deviation.
- The probabilities are nonnegative and sum to one. The mean is E[X]=0+4(3/10)+10(1/10)=11/5.
- The second raw moment is E[X²]=16(3/10)+100(1/10)=74/5.
- The variance is 74/5−(11/5)²=249/25=9.96, so SD(X)=√249/5≈3.156.
- The mean and standard deviation have loss units, while variance has squared loss units. The most likely value 0 differs from the mean 2.2, which is not an available outcome.
Mean 11/5, second moment 74/5, variance 249/25 and standard deviation√249/5.
Average a function without finding its distribution
X has density 2 x on(0,1), and G=1+3 X². Find E[G] and Var(G), then compare E[G] with 1+3(E[X])².
- Direct integration gives E[X²]=∫₀¹2 x³dx=1/2 and E[X⁴]=∫₀¹2 x⁵dx=1/3.
- Linearity and LOTUS give E[G]=1+3/2=5/2. The variance of X² is 1/3−1/4=1/12.
- An affine scale of X² gives Var(G)=9/12=3/4.
- Since E[X]=∫₀¹2 x²dx=2/3, the expression 1+3(E[X])² equals 7/3, not 5/2. Nonlinear transformation and averaging do not generally commute.
E[G]=5/2 and Var(G)=3/4;1+3(E[X])²=7/3 is a different quantity.
Use dependence for spread but not for mean linearity
X is 1 with probability 3/10 and 0 otherwise; Y=1−X. Find the mean and variance of 2 X+5 Y and their covariance.
- Linearity gives E[2 X+5 Y]=2(3/10)+5(7/10)=41/10 without any independence assumption.
- Because 2 X+5 Y=5−3 X and Var(X)=(3/10)(7/10)=21/100, the variance is 189/100.
- The product XY is always zero, so Cov(X,Y)=0−(3/10)(7/10)=−21/100.
- The sum formula checks the result:4(21/100)+25(21/100)+20(−21/100)=189/100. Omitting the covariance would calculate another dependence model.
Mean 41/10, variance 189/100 and Cov(X,Y)=−21/100.
Convert location, spread and covariance consistently
Celsius temperature C has mean 20 and variance 4. For F=9 C/5+32, find E[F], Var(F), SD(F) and Cov(C,F).
- The affine mean rule gives E[F]=(9/5)20+32=68°F.
- Variance uses the squared slope: Var(F)=(81/25)4=324/25°F². Thus SD(F)=18/5°F.
- Covariance is Cov(C,F)=(9/5)Var(C)=36/5, with units°C·°F.
- The offset 32 affects location but disappears from centered deviations. These are unit representations of the same temperature, not evidence of a change in physical variability.
Mean 68°F, variance 324/25°F², standard deviation 18/5°F, covariance 36/5°C·°F.
Retain the cross term in a weighted difference
Var(X)=9, Var(Y)=16 and Cov(X,Y)=6. Find correlation and Var(2 X−Y), and check the covariance bound.
- The standard deviations are 3 and 4, soρ=6/(3×4)=1/2.
- Cauchy–Schwarz permits|Cov|≤3×4=12. The stated covariance 6 passes this necessary pairwise consistency check.
- The weighted variance is 4×9+16−4×6=28.
- Ignoring the covariance would give 52. Positive co-movement reduces this difference’s variation because its two coefficients have opposite signs.
Correlation 1/2 and variance 28; covariance 6 lies within the bound 12.
Find dependence that correlation misses
X is uniform on{−1,0,1}, and Y=X². Calculate covariance and correlation, then test independence.
- E[X]=0, E[Y]=2/3 and E[XY]=E[X³]=0. Therefore covariance is zero.
- Var(X)=2/3 and Var(Y)=2/3−4/9=2/9, both positive. Correlation is defined and equals zero.
- Given the positive-probability event X=0, Y=0 is certain. Unconditionally P(Y=0)=1/3.
- The unequal conditional and unconditional probabilities disprove independence. A deterministic nonlinear relationship can be uncorrelated.
Covariance and correlation are zero, but X and Y are dependent.
Account for variation of the group means
S=1 with probability 1/4. Conditional on S=0, X has mean 4 and variance 1; conditional on S=1, mean 12 and variance 9. Find the overall mean and variance and the best group-based squared-error prediction.
- Total expectation gives E[X]=(3/4)4+(1/4)12=6.
- The within-group variance average is(3/4)1+(1/4)9=3.
- The conditional means have variance(12−4)²(1/4)(3/4)=12. Total variance is 3+12=15.
- Predicting 4 in group 0 and 12 in group 1 gives expected squared error 3. Predicting the overall mean 6 everywhere gives 15. The difference 12 is the variation explained by knowing the group in this predictive sense.
Overall mean 6 and variance 15; the conditional-mean predictor has expected squared error 3.
Include uncertainty in the number of trials
N equals 1 with probability 1/3 and 7 with probability 2/3. A trial sequence independent of N has independent binary outcomes with pass probability 2/5. Let X count passes in the first N trials. Find E[X] and Var(X).
- E[N]=1/3+14/3=5, while E[N²]=1/3+98/3=33, so Var(N)=8.
- Given N, indicator sums give E[X|N]=(2/5)N and Var(X|N)=(6/25)N.
- Total expectation gives E[X]=(2/5)5=2.
- Total variance is(6/25)E[N]+(4/25)Var(N)=30/25+32/25=62/25. The second term would be lost by replacing N with its mean inside a conditional variance.
The pass count has mean 2 and variance 62/25.
Use tail sums with their correct starting index
N≥1 has P(N≥k)=(1/3)^{k−1} for k≥1. Find its mean, second moment and variance.
- The tail mean isΣ_{k≥1}(1/3)^{k−1}=1/(1−1/3)=3/2.
- For q=1/3, useΣq^{k−1}=1/(1−q) andΣkq^{k−1}=1/(1−q)². Then E[N²]=Σ(2 k−1)q^{k−1}=2/(1−q)²−1/(1−q)=3.
- Subtract the squared mean: Var(N)=3−9/4=3/4.
- The law starts at one. A tail qᵏ beginning at k=1 would describe a different nonnegative count that can be zero. Indexing is part of the model.
Mean 3/2, second moment 3 and variance 3/4.
Compare convex and concave transformations
X is equally likely to be 2 or 8. Compare E[X²] with(E[X])² and E[log X] with log(E[X]).
- The mean is 5. The mean square is(4+64)/2=34, larger than 25.
- The square is convex, so its comparison has Jensen’s directionφ(E[X])≤E[φ(X)].
- The mean logarithm is(log 2+log 8)/2=log 4, smaller than log 5. The logarithm is concave on positive inputs, reversing the inequality.
- All values and transformed values are finite here. The example does not support a universal rule that averaging increases every function.
34>25 for the square, while log 4<log 5 for the logarithm.
Verify a moment bound and an equality case
A law has E[X]=10 and Var(X)=9. Bound P(|X−10|≥6). Check a law with masses 1/8 at 4,3/4 at 10 and 1/8 at 16.
- Chebyshev gives P(|X−10|≥6)≤9/36=1/4.
- The proposed masses sum to one and their mean is(4+16)/8+10(3/4)=10.
- The squared deviations are 36,0,36, giving variance 36(1/8+1/8)=9.
- The two extreme values are exactly six from the mean and together have mass 1/4, attaining the weak-inequality tail bound. Another law with those moments need not attain it.
The tail is at most 1/4, and the proposed three-point law attains that bound.
Inspect both signed tails before using symmetry
For standard Cauchy density 1/[π(1+x²)], determine the mean status and compare symmetric cutoffs with cutoffs[−R,2 R].
- The density normalizes by the arctangent integral. Its positive first-moment integral is log(1+R²)/(2π), which tends to infinity.
- The negative absolute first-moment integral also diverges. Both signed parts are infinite, so the expectation is undefined.
- Symmetric truncated integrals are zero, defining a principal value. Asymmetric integrals are log[(1+4 R²)/(1+R²)]/(2π), tending to log 2/π.
- Neither the median zero nor the principal value zero supplies a finite mean. Under this lesson’s finite-mean convention, variance and standard deviation are undefined, even though the nonnegative raw second moment diverges.
The mean is undefined. Symmetric principal value 0 and asymmetric limit log 2/π are different truncation operations.
Try it yourself
For p(k)=1/[k(k+1)], k≥1, validate normalization and classify the mean.
Show the answer and reasoning
The law normalizes, and its nonnegative extended mean is+∞.
The masses telescope as 1/k−1/(k+1). The mean sum becomesΣ1/(k+1), which diverges. This is defined nonnegative infinity, rather than an undefined signed cancellation.
For k≥1, P(X=k)=P(X=−k)=3/(π²k²). Classify the expectation. You may useΣ_{k≥1}1/k²=π²/6.
Show the answer and reasoning
The expectation is undefined.
The two sides normalize to one using the supplied series identity. Each first-moment half is(3/π²)Σ1/k=∞. Symmetry cannot subtract two infinite halves into zero.
Defineζ(s)=Σ_{k≥1}k^{−s} for s>1. For p(k)=1/[ζ(3)k³], k≥1, classify the mean and variance.
Show the answer and reasoning
The meanζ(2)/ζ(3) is finite; the variance is infinite.
The first-moment series is summable, while the raw second moment is(1/ζ(3))Σ1/k=∞. Since the mean is finite, the centered second moment is a well-defined nonnegative infinity.
X is uniform on(−1,1). Find E[2 X²−X] without deriving the transformed density.
Show the answer and reasoning
The expectation is 2/3.
Symmetry gives E[X]=0, and direct integration gives E[X²]=1/3. LOTUS and finite linearity yield 2(1/3)−0.
Let Y=X, with X taking±1 equally. Find E[X+Y] and Var(X+Y).
Show the answer and reasoning
The mean is 0 and variance 4.
The sum is 2 X. Its variance is 4 Var(X)=4. Adding only the two unit variances would omit 2 Cov(X,Y)=2.
P(A)=2/5, P(B)=3/5 and P(A∩B)=3/10. Find Cov(1_A,1_B) and Var(1_A+1_B).
Show the answer and reasoning
Covariance 3/50 and count variance 3/5.
The covariance is 3/10−6/25=3/50. Each indicator variance is 6/25, so the sum variance is 6/25+6/25+2(3/50)=3/5. Marginals alone would not determine it.
Draw three items uniformly without replacement from ten, four marked. Find the mean and variance of the marked count.
Show the answer and reasoning
Mean 6/5 and variance 14/25.
Each marked-draw indicator has probability 2/5 and variance 6/25. A pair has joint probability(4/10)(3/9)=2/15 and covariance−2/75. Therefore the count variance is 3(6/25)+6(−2/75)=14/25; its mean uses linearity alone.
Six labelled objects are uniformly permuted among six labelled positions. Find the expected number in their own position.
Show the answer and reasoning
The expected number is 1.
Each match indicator has probability 1/6. Their six expectations add to one without independence. The permutation constrains joint matches but does not change this marginal argument.
E[X]=5, Var(X)=9 and Y=7−2 X. Find E[Y], Var(Y) and Cov(X,Y).
Show the answer and reasoning
Mean−3, variance 36 and covariance−18.
The affine mean is 7−10. Variance uses the squared scale 4, while covariance retains the scale−2. The offset affects neither centered spread nor covariance.
Var(X)=4, Var(Y)=9 and Cov(X,Y)=−3. Find correlation and Var(X+Y).
Show the answer and reasoning
Correlation−1/2 and sum variance 7.
Divide−3 by standard-deviation product 2×3. The sum variance is 4+9+2(−3)=7. Negative covariance reduces the sum’s variation.
Could variances 4 and 9 coexist with covariance 7 for two L² variables?
Show the answer and reasoning
No. The proposed moments are inconsistent.
Cauchy–Schwarz requires absolute covariance at most√(4×9)=6. Equivalently the proposed two-by-two covariance matrix fails positive semidefiniteness.
Two partition cells have probabilities 3/5,2/5 and conditional means 10,20. Find the overall mean.
Show the answer and reasoning
The overall mean is 14.
Total expectation gives(3/5)10+(2/5)20. An equal average would use the wrong partition weights.
For the preceding partition and means, conditional variances are 4 and 9. Find total variance.
Show the answer and reasoning
The total variance is 30.
The within-group term is(3/5)4+(2/5)9=6. The between-group term is(3/5)(2/5)(20−10)²=24. Both contribute; dropping the varying means would leave only 6.
For X∈L², let m=E[X|Y] and h(Y)∈L². Explain why E[(X−m)h(Y)]=0.
Show the answer and reasoning
The residual is orthogonal, in the expected-product sense, to every such Y-based function.
The product is integrable by Cauchy–Schwarz. Condition on Y, pull out its measurable factor h(Y), and use E[X−m|Y]=0. Averaging gives zero. This is the vanishing cross term in least-square prediction.
N is nonnegative integer-valued with P(N≥k)=2^{−k} for k≥1. Find its mean, second moment and variance.
Show the answer and reasoning
Mean 1, second moment 3 and variance 2.
The tail mean isΣ_{k≥1}2^{−k}=1, and the second-moment tail sumΣ(2 k−1)2^{−k}=3. The law allows N=0; substituting a trials-until-success formula would introduce an incorrect shift.
X equals 1 or 9 with equal probability. Compare E[√X] and√E[X].
Show the answer and reasoning
E[√X]=2<√5=√E[X].
Average the transformed values 1 and 3, then compare with the square root of the mean 5. Square root is concave on this domain, so Jensen’s inequality has the reversed direction.
E[X]=100 and Var(X)=25. Bound P(|X−100|≥20) and its complementary inside probability.
Show the answer and reasoning
The outside probability is at most 1/16; P(|X−100|<20) is at least 15/16.
Chebyshev gives 25/400. Complement the weak outside inequality carefully: the exact complementary event uses a strict distance below 20. No normal-shape assumption is required.
What to carry forward
- Expectation averages a recording against its law. A finite observation does not ensure a finite moment, and a mean need not be a possible or most likely value.
- Nonnegative infinity is a defined extended expectation; two infinite signed halves give an undefined expectation. Symmetric principal values do not repair that failure.
- Finite linearity needs integrability but not independence. Product factorization and simplified sum variances need additional joint information.
- Variance, standard deviation, covariance and correlation have distinct units and existence conditions; zero covariance does not generally imply independence.
- Total variance includes both average conditional spread and variation of conditional means. The conditional mean minimizes expected squared prediction error.
- Tail identities and convexity inequalities require their stated nonnegativity or integrability conditions.
- Markov and Chebyshev provide guarantees from limited moments; they do not reconstruct a distribution or validate a sampling model.
References
Sources for the concepts and teaching approaches in this article.
Massachusetts Institute of Technology3 sources
- Fundamentals of Probability, Lecture 8MIT OpenCourseWare; 6.436J/15.085J, Fall 2018Course notes · PDFAbstract Integration IIDiscrete Random Variables and Their ExpectationsMore on Discrete Random Variables and Their Expectations
- More integration and expectationScott Sheffield; MIT OpenCourseWareCourse notes · PDF
- Probabilistic Systems Analysis and Applied Probability, Lecture 13MIT OpenCourseWare; Munther DahlehCourse notes · PDFIterated ExpectationsPrediction; Covariance and CorrelationWeak Law of Large Numbers
- Cauchy DistributionNIST/SEMATECH e-HandbookOfficial reference
- Frequently Asked Questions: Computing expectationsAni Adhikari; University of California, BerkeleyUniversity teaching notes