The expectation (expected value, mean) of a random variable X is the probability-weighted average of its possible values:
Discrete:E[X]=x∑x⋅pX(x)
Continuous:E[X]=∫−∞∞x⋅fX(x)dx
Expectation is the centre of mass of the distribution — the balancing point if you placed probability mass along a number line.
Worked examples:
Bernoulli(p):E[X]=0⋅(1−p)+1⋅p=p.
Binomial(n,p):E[X]=np (derivable from the sum-of-Bernoullis view).
Uniform(a,b):E[X]=2a+b (the midpoint).
Exponential(λ):E[X]=1/λ (rate = inverse of mean wait time).
LOTUS — Law of the Unconscious Statistician. To find E[g(X)], you do not need the distribution of g(X). You integrate/sum g(x) against the distribution of X:
E[g(X)]=x∑g(x)pX(x)or∫g(x)fX(x)dx.
Worked example — E[X2] for a fair die. With p(x)=1/6 for x=1,…,6:
Linearity is the most powerful shortcut in probability. For any random variables X,Y and constants a,b:
E[aX+bY]=aE[X]+bE[Y].
No independence required. The expectation of a sum is always the sum of expectations, regardless of whether X and Y are independent, correlated, or even deterministically linked.
Worked example — dependent variables. Let X be the roll of a die, and Y=7−X (so Y is completely determined by X). Then E[X]=3.5, E[Y]=3.5, and
E[X+Y]=E[X]+E[Y]=7.
Indeed X+Y=7 always, so E[7]=7. Linearity works despite perfect dependence.
Binomial expectation via linearity:X=∑i=1nYi where Yi∼Bernoulli(p). Even if the Yi were correlated, E[X]=∑E[Yi]=np (for i.i.d. they happen to be independent, but linearity does not need that).
Covariance measures how two variables move together:
Cov(X,Y)=E[(X−μX)(Y−μY)].
Computational form: Cov(X,Y)=E[XY]−E[X]E[Y].
Positive covariance: X above its mean tends to happen with Y above its mean.
Negative covariance: opposite directions.
Zero covariance: no linear relationship detected.
Properties:
Cov(X,X)=Var(X).
Cov(X,Y)=Cov(Y,X) (symmetric).
Cov(aX+b,cY+d)=acCov(X,Y).
Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y).
The last formula shows why variance of a sum is not always sum of variances — the covariance term can add or subtract.
Correlation standardises covariance to the range [−1,1]:
ρ(X,Y)=σXσYCov(X,Y).
ρ=1: perfect positive linear relationship.
ρ=−1: perfect negative linear relationship.
ρ=0: uncorrelated.
Critical warning — uncorrelated = independent. Independence implies uncorrelated, but uncorrelated does not imply independence. Example: let X∼Uniform(−1,1) and Y=X2. Then Cov(X,Y)=E[X3]−E[X]E[X2]=0−0⋅(1/3)=0. They are uncorrelated but perfectly dependent — knowing X tells you Y exactly.
Correlation only captures linear dependence. Non-linear relationships (quadratic, periodic) can have zero correlation but strong dependence.
Worked example — joint table. Suppose X and Y have the following joint PMF:
The conditional expectationE[X∣Y=y] is the average of X over the subset of outcomes where Y=y. It is a function of y: for each possible value of Y, we get a (potentially different) expected value of X.