Foundations — Covariance and correlation
This page is the toolbox room. Before you enter Covariance and Correlation, we lay out every symbol, picture, and idea that note quietly assumes. Read top to bottom — each rung of the ladder rests on the one below it.
0. The raw material: a random variable
Picture a dartboard experiment. Every throw is an outcome; the rule "measure how far the dart landed from the centre, in cm" turns each throw into a number. That number-valued rule is .
- The small letter means one particular value can take.
- The capital letter means the whole random rule, before we know the result.
We need this because covariance compares two such rules, and , measured on the same experiment (same dart throw gives both a horizontal position and a vertical position ).

Prerequisite depth lives in Expectation of Random Variables and Variance and Standard Deviation — we rebuild just what we need here.
1. Probability : how likely each value is
Before we can average, we need the symbol that says how likely.
Picture a loaded die whose faces have unequal chances. The list of six heights (one per face), each between and and summing to , is the pmf. We need because every average below is a probability-weighted one — no probabilities, no averaging.
2. The average: , and the mean
For a discrete variable that takes value with probability :
Read this literally: walk through every value the variable can take, weight it by how likely it is, add them up. The (capital Greek "S", for "sum") just means "add over all cases".
The balance-point idea deserves a picture.

Why a separate symbol? Because we will subtract it so often — — that writing each time would clutter the page.
3. The deviation:
This is the heart of everything to come. Look at the sign:
- ⇒ came out above average (a high day).
- ⇒ came out below average (a low day).
- ⇒ landed exactly on average.
Why subtract the mean? Covariance cares about movement around the centre, not the centre itself. If everyone earns ₹1000 more, nobody's "high day / low day" pattern changes — subtracting throws away the location and keeps only the wiggle.

4. Squaring one deviation: Variance and
Before comparing two variables, understand the one-variable case the parent note builds on.
Why square? A raw deviation is sometimes , sometimes ; averaging them cancels to zero (that is what "balance point" means). Squaring makes every deviation positive, so wiggles can no longer cancel. Big wiggles get counted; direction is thrown away.
We need and because correlation divides covariance by to cancel units. More in Variance and Standard Deviation.
5. Multiplying TWO deviations: covariance and its shortcut
Now the leap from one variable to two. Multiply the two deviations and read the sign of the product — this is the single trick the whole topic rests on.

Covariance is then just the average of this product: If agreements outweigh disagreements, the average is positive. That is the entire definition, now fully earned.
6. The correlation symbol , its leash, and where it breaks
- : perfect agreement (points fall on an upward line).
- : perfect disagreement (points fall on a downward line).
- : no linear teamwork.
Why a leash? Raw covariance can be any size and carries units (kg·cm), so "big covariance" tells you nothing about strength. The leash makes a fair, unitless report card.
7. Two supporting ideas the topic leans on
Prerequisite map
The diagram below is drawn with mermaid (a plain-text way to specify boxes and arrows). Read each box as a concept and each arrow as "must understand before": start at the bottom-source boxes and follow the arrows upward — the flow ends at the parent topic. If your reader shows it as raw text, just trace the pairs in words: random variable → expectation → mean → deviation, and from deviation the ladder splits into variance and product of deviations, both feeding covariance, which together with variance feeds correlation.
In plain words: probabilities let us average; averaging gives the mean; the mean lets us measure deviations; deviations (squared) give variance and (paired, multiplied) give covariance; covariance divided by the two sigmas gives correlation — the doorway into Covariance and Correlation. The sideways ideas also feed Linear Regression and the Covariance Matrix.
Equipment checklist
Test yourself — cover the right side.
What does a capital mean versus a small ?
What is and what constraints does a pmf satisfy?
What does the machine output?
Compute for a discrete variable in one formula.
How does change for a continuous variable?
State the linearity property of expectation.
What is ?
What is the deviation and why subtract the mean?
Why do we square the deviation in variance?
What is and why take a square root?
Derive in one line of reasoning.
What sign does take when both are below their means?
Why divide covariance by to get ?
When is undefined?
Give the intuitive reason .
Does always hold?
Connections
- Expectation of Random Variables — the machine every formula uses.
- Variance and Standard Deviation — the one-variable case covariance generalises.
- Independence of Random Variables — why independence forces .
- Cauchy–Schwarz Inequality — the reason stays in .
- Linear Regression — uses these same deviations to fit a line.
- Covariance Matrix — bundles all pairwise covariances together.
- Covariance and Correlation — the parent topic this page prepares you for.