Worked examples — Covariance and correlation
4.9.12 · D3· Maths › Probability Theory & Statistics › Covariance and correlation
The scenario matrix
Neeche har problem is table ka ek cell hai. Agar ek cell filled hai, toh aapne dekh liya hai ki use kaise handle karna hai.
| Cell | Relationship type | Kya special / degenerate hai | Example |
|---|---|---|---|
| A | Positive, non-extreme | ordinary discrete joint pmf | Ex 1 |
| B | Negative | , deviations disagree karte hain | Ex 2 |
| C | Exactly zero, linear boundary | genuine symmetry se, no dependence issue | Ex 3 |
| D | Zero cov but dependent | famous trap | Ex 4 |
| E | Perfect | Cauchy–Schwarz ka equality case | Ex 5 |
| F | Perfect | negative-slope exact line | Ex 5 |
| G | Degenerate input | ek variable constant hai () — undefined! | Ex 6 |
| H | Real-world, with units | covariance kg·cm carry karta hai; units strip karta hai | Ex 7 |
| I | Exam twist (toolbox, not sum) | bilinearity / use karo raw ki jagah | Ex 8 |
Kuch bhi compute karne se pehle, ek picture jo covariance ke sign ka geometrically matlab fix kare — yeh poore page ke liye hamara compass hoga.

Example 1 — Cell A: ordinary positive relationship
-
Marginals. Joint ko doosre variable ke upar sum karo. , toh . , toh . Yeh step kyun? 0/1 variable ka Expectation sirf hota hai; koi bhi deviation ki baat karne se pehle humein dono means chahiye.
-
. Product sirf tab hota hai jab dono 1 hon. . Yeh step kyun? woh piece hai jo hamare working formula ko chahiye; har doosra pair product ko zero kar deta hai.
-
Covariance. . Yeh step kyun? Yeh parent se shortcut formula hai — haath se deviations build karne ki zaroorat nahi.
-
Standard deviations. hai Bernoulli: , . hai Bernoulli: . Yeh step kyun? $\sigma$ covariance ko mein rescale karta hai.
-
Correlation. .
Verify: ✓, positive as forecast ✓. Sanity: agar hum saara mass aur par load karte toh expect karte; yahan "disagree" corners abhi bhi mass carry karte hain, toh ek moderate reasonable hai.
Example 2 — Cell B: negative relationship
-
Marginals. . Numbers ki symmetry se . Yeh step kyun? Pehle jaisa hi — pehle means nikalo.
-
. Sirf contribute karta hai: .
-
Covariance. . Yeh step kyun? Negative product-average compass confirm karta hai: disagree quadrants jeete.
-
Correlation. Dono Bernoulli hain, toh . .
Verify: ✓, negative ✓. Note karo yeh parent note ke Example 1 ka mirror image hai (jiska tha): agree-corners se disagree-corners par weight swap karne se poore relationship ka sign flip ho jaata hai.
Example 3 — Cell C: exactly zero from genuine symmetry
-
Means. , isi tarah . Yeh step kyun? 0 ke aas paas symmetric values mean ko 0 banate hain — yeh sab kuch simplify karta hai.
-
. Chaar products , har ek weight : .
-
Covariance. .
-
Correlation. (har ek ka variance hai), toh .
Verify: ✓. Cross-check independence: equals , aur similarly saare cells ke liye — toh yahan independence genuinely hold karta hai. Is baat ko agale example se contrast karo.
Example 4 — Cell D: zero covariance, lekin fully dependent (the trap)
-
Mean of . . Yeh step kyun? Symmetric spread banata hai, jo correction term ko kill karega.
-
. Cubes: . . Yeh step kyun? substitute karne se sirf ka moment ban jaata hai.
-
Covariance. .
-
Independence check — yeh FAIL karta hai. lo: toh certainty ke saath, toh . jaanna ki distribution change karta hai ⇒ not independent.
Verify: ✓ phir bhi dependence total hai. Yeh parent ke [!mistake] callout se one-way street hai: independence , lekin independence. Covariance relationship ke symmetric (even) part ke liye andha hai.
Example 5 — Cells E & F: perfect-line boundary

-
Up-slope means. ; . Yeh step kyun? Sample correlation ko deviations form karne ke liye sample means chahiye.
-
Deviation sums. ke deviations: ; ke: (exactly the -deviations, kyunki slope hai). . ; . Yeh step kyun? — ka sample version.
-
Up-slope . .
-
Down-slope. Har -deviation ka sign flip hota hai, toh jabki unchanged rehte hain (squares). . Yeh step kyun? Toolbox ki property 5 hai — ko negative scale se multiply karna flip karta hai, magnitude preserved.
Verify: aur ✓, dono ki boundary par. Yahi woh jagah hai jahan Cauchy–Schwarz proof mein hota hai — deviations perfectly proportional hain. Dekho Linear Regression: ek perfect line par fitted slope data ko zero error ke saath reproduce karta hai, toh .
Example 6 — Cell G: degenerate input, undefined
-
ka deviation. , toh har outcome ke liye. Yeh step kyun? Ek constant ka zero variance hota hai — yeh cell ki degenerate feature hai.
-
Covariance. . Yeh step kyun? Expectation ke andar ka koi bhi factor poori cheez zero kar deta hai.
-
Correlation attempt. , toh — undefined (0/0, "0" nahi).
Verify: ✓. Lekin mat report karo : ke saath ratio hai, aur correlation simply defined nahi hota jab koi bhi variable constant ho. Yeh boundary case hai jo log silently mishandle karte hain — data mein ek constant column ki koi correlation nahi hoti, "zero correlation" nahi.
Example 7 — Cell H: real-world word problem with units
-
Means. cm; kg. Yeh step kyun? Deviations ko sample means chahiye.
-
Deviation products. -devs: ; -devs: . . Sample covariance cm·kg. Yeh step kyun? Sample covariance denominator mein use karta hai; product mixed units carry karta hai.
-
. ; . .
-
Metres mein switch. Heights se divide ho jaati hain: bilinearity se , toh sample covariance m·kg ho jaata hai. Lekin bhi se divide hota hai, toh mein factors cancel ho jaate hain: hi rehta hai. Yeh step kyun? Property 5 — scale-invariant hai; covariance nahi.
Verify: covariance cm·kg (unit-bearing) ✓; ✓. Yeh exactly parent ka doosra [!mistake] hai: covariance ka number ek harmless unit change mein badal gaya, jabki strength nahi hili. Strength ko hamesha se judge karo.
Example 8 — Cell I: exam twist (toolbox use karo, raw sum nahi)
-
bilinearity se. . Yeh step kyun? Toolbox property 2: shifts vanish ho jaate hain, scales multiply out karte hain. Kisi bhi computation se zyada faster aur cleaner.
-
Pehle . . Yeh step kyun? Sign rule apply karne ke liye humein yeh chahiye.
-
scale-invariance se. , toh . Yeh step kyun? Property 5 — ek negative scale sign flip karta hai, magnitude preserved.
-
. Pehle ; . . Yeh step kyun? Property 3, variance-of-a-sum identity; negative covariance sum ki spread reduce karta hai.
Verify: ; ✓; ✓ (variance non-negative hona chahiye). ka direct check: ✓ — step 3 se match karta hai.
Recall Kaun sa cell kaun sa tha?
Positive ordinary ::: Ex 1 (cell A), . Negative ::: Ex 2 (cell B), . Honest zero (independent) ::: Ex 3 (cell C), AUR independent. Zero-cov trap (dependent) ::: Ex 4 (cell D), lekin . Perfect line ::: Ex 5 (cells E,F), aur . Constant input ::: Ex 6 (cell G), UNDEFINED (0/0). Units word problem ::: Ex 7 (cell H), cov units ke saath badlta hai, nahi. Toolbox twist ::: Ex 8 (cell I), bilinearity + variance-of-sum.
Connections
- Covariance and Correlation — yeh page uska worked-example companion hai.
- Expectation of Random Variables — yahan har mean aur .
- Variance and Standard Deviation — woh 's jo rescale karte hain, aur degenerate case.
- Independence of Random Variables — Ex 3 (genuine) vs Ex 4 (fails).
- Cauchy–Schwarz Inequality — Ex 5 mein boundary.
- Linear Regression — perfect line ⇒ .
- Covariance Matrix — Ex 8 ka toolbox poore random vectors tak scale karta hai.