4.9.12 · D1Probability Theory & Statistics

Foundations — Covariance and correlation

2,462 words11 min readBack to topic

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 ).

Figure — Covariance and correlation

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.

Figure — Covariance and correlation

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.

Figure — Covariance and correlation

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.

Figure — Covariance and correlation

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.

Random variable X

Probability P and pmf

Expectation E of X

Mean mu

Deviation X minus mu

Variance and sigma

Product of two deviations

Covariance

Correlation rho

Independence

Cauchy Schwarz

Covariance and 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 ?
is the whole random rule; is one particular value it can take.
What is and what constraints does a pmf satisfy?
The probability equals the value ; all and they sum to .
What does the machine output?
The long-run (probability-weighted) average of whatever random quantity you feed it.
Compute for a discrete variable in one formula.
.
How does change for a continuous variable?
Replace the sum by an integral of ; the "value times likelihood, accumulated" idea is unchanged.
State the linearity property of expectation.
.
What is ?
A shorthand name for , the mean / balance point of .
What is the deviation and why subtract the mean?
How far above/below its own average landed; subtracting removes location so only the wiggle remains.
Why do we square the deviation in variance?
So and wiggles can't cancel; it measures spread size, discarding direction.
What is and why take a square root?
; the root restores the original units.
Derive in one line of reasoning.
Expand , apply using linearity, and the mean-terms collapse to .
What sign does take when both are below their means?
Positive — , they agree.
Why divide covariance by to get ?
To cancel units and bound the result in for fair comparison.
When is undefined?
When or (a constant variable), because we would divide by zero.
Give the intuitive reason .
Cov is a dot-product of deviation-arrows, which can't exceed the product of their lengths (Cauchy–Schwarz); parallel arrows give .
Does always hold?
No — only when are independent; the difference is exactly the covariance.

Connections