Hassan Ijaz

Ai, Web & Design
← Back to all topics
Probability FundamentalsTopic 7 of 58

Expectation, variance, and covariance

Visual scatter plot generator where users can drag points and see mean, variance, and covariance update in real-time with geometric interpretations

Concept Overview

Expectation (mean) and variance are fundamental measures that characterize probability distributions. The expectation tells us the "center" of a distribution, while variance measures its "spread". Covariance extends these concepts to measure relationships between variables.

Expectation (Expected Value)

The expectation is the theoretical average value of a random variable over many repetitions.

Discrete: E[X] = Σ x · P(X = x)

Sum of each value times its probability

Continuous: E[X] = ∫ x · f(x) dx

Integral of value times density

Key Properties: E[aX + b] = aE[X] + b, E[X + Y] = E[X] + E[Y]

Variance

Variance measures the average squared deviation from the mean - how spread out the values are.

Var(X) = E[(X - μ)²] = E[X²] - (E[X])²

Average squared distance from mean

SD(X) = σ = √Var(X)

Standard deviation - in original units

Key Properties: Var(aX + b) = a²Var(X), Var(X + Y) = Var(X) + Var(Y) + 2Cov(X,Y)

Covariance

Covariance measures how two variables change together - positive means they tend to increase together, negative means one increases as the other decreases.

Cov(X,Y) = E[(X - μ_X)(Y - μ_Y)] = E[XY] - E[X]E[Y]

Average product of deviations from means

Corr(X,Y) = ρ = Cov(X,Y) / (σ_X · σ_Y)

Correlation: normalized to [-1, 1]

Geometric Interpretation

Mean as Balance Point

The mean is where the distribution would balance if values were weights

Variance as Spread

Larger variance means data is more spread out from the center

Covariance as Tilt

Shows direction and strength of linear relationship

Important Special Cases

  • Independent Variables:If X and Y are independent, then Cov(X,Y) = 0 and Var(X+Y) = Var(X) + Var(Y)
  • Linear Combinations:E[aX + bY] = aE[X] + bE[Y] always holds
  • Perfect Correlation:ρ = ±1 means perfect linear relationship

Practical Example: Portfolio Risk

For a portfolio with two assets:

  • Expected return: weighted average of individual returns
  • Risk (variance): depends on individual variances AND covariance
  • Negative correlation between assets reduces overall risk!

The interactive visualization below lets you drag points to see how mean, variance, and covariance update in real-time. Notice the geometric interpretations as you move the data points around.

Interactive Visualization

Loading interactive visualization...

Visual scatter plot generator where users can drag points and see mean, variance, and covariance update in real-time with geometric interpretations