1.3.9 · HinglishProbability & Statistics

Covariance and correlation

2,470 words11 min readRead in English

1.3.9 · AI-ML › Probability & Statistics

Overview

Covariance aur correlation measure karte hain ki do random variables saath-saath kaise change karte hain. Ye answer karte hain: "Jab upar jaata hai, toh kya bhi upar jaata hai (positive), neeche jaata hai (negative), ya unrelated rehta hai (zero)?" Ye concepts machine learning mein feature relationships, dimensionality reduction (PCA), aur regression samajhne ke liye foundational hain.


Core Intuition


Definitions and Derivations

Computational Form Ki Derivation

Definition se shuru karo:

Product expand karo:

Expectation ki linearity apply karo (expectation addition par distribute ho jaati hai):

Ye step kyun? Constants ko expectations ke bahar nikaala ja sakta hai:

Substitute karo aur :

Simplify karo (beech ke do terms cancel hokar ek reh jaata hai):

Interpretation:

  • Agar aur independent hain, toh , isliye .
  • Positive covariance: aur saath-saath increase karte hain.
  • Negative covariance: jab increase karta hai, decrease karta hai.
  • Units: covariance ke units hote hain (jaise meters × kilograms), jisse magnitude interpret karna mushkil ho jaata hai.

Standard Deviations Se Normalize Kyun Karte Hain?

Intuition: Covariance aur ke scales par depend karta hai. Agar hum height ko meters ki jagah millimeters mein measure karein, toh covariance se scale ho jaata hai! se divide karne par ye scale dependence hat jaati hai.

Bounds ki derivation ():

Standardized variables consider karo:

Inका mean aur variance hota hai. Correlation hai:

Cauchy-Schwarz inequality kehti hai:

Ye step kyun? standardization ki wajah se.

Isliye . Equality tab hold hoti hai jab (perfect linear relationship).


Sample Estimates (Finite Data)

Practice mein, hum samples se estimate karte hain:


Visual Understanding

Figure — Covariance and correlation

Diagram alag-alag correlation values ke liye scatter plots dikhata hai. Notice karo ki:

  • : bina kisi trend ke cloud
  • : moderate trend
  • : points bilkul ek line par

Worked Examples


Common Mistakes


Key Properties and Facts


Machine Learning Context

ML mein covariance/correlation kyun matter karta hai:

  1. Feature Engineering: Highly correlated features redundant ho sakte hain (regression mein multicollinearity).
  2. PCA (Principal Component Analysis): Maximum variance ki directions dhundhta hai = covariance matrix ke eigenvectors.
  3. Correlation-based Feature Selection: Target ke saath wale features remove karo.
  4. Gaussian Processes: Covariance functions (kernels) data points ke beech similarity define karte hain.
  5. Portfolio Optimization: Finance ML mein, covariance matrices asset co-movements model karti hain.

Feynman Technique (ELI12)

Recall Aise Samjhao Jaise Main 12 Saal Ka Hoon

Socho tum aur tumhara dost dono skateboard seekh rahe ho. Har hafte, tum dono harder tricks try karte ho.

Covariance ye poochne jaisa hai: "Jab main harder trick seekhta hoon, kya mere dost us hafte bhi harder trick seekhte hain?" Agar haan, covariance positive hai. Agar jab main better karta hoon toh wo worse karte hain, toh negative hai. Agar koi pattern nahi hai, toh zero hai. Lekin baat ye hai: agar main apni progress "tricks learned" mein measure karoon aur wo "hours practiced" mein, toh numbers messy ho jaate hain. Maan lo maine 5 tricks sikhe, unhone 20 ghante practice kiye—hum compare kaise karein?

Correlation ye fix karta hai sab kuch ek hi scale -1 se +1 par rakhke. Ye hamari teamwork ko rate karne jaisa hai: +1 matlab hum perfectly sync mein hain (jab main improve karta hoon, wo bhi apni respective ranges ke relative exact same amount improve karte hain), -1 matlab hum perfect opposites hain, aur 0 matlab hum apna-apna kaam kar rahe hain bina kisi pattern ke.

Toh: covariance = raw teamwork, correlation = report card scale par teamwork.


Mnemonic


Active Recall Flashcards

#flashcards/ai-ml

Random variables aur ke beech covariance ki definition kya hai?
Pearson correlation coefficient ka formula kya hai?
, jo covariance ko mein normalize karta hai
Correlation ki range kya hai?
(dimensionless, Cauchy-Schwarz inequality se)
Agar aur independent hain, toh kya hai?
(lekin converse hamesha true nahi hota!)
Kya imply karta hai ki aur independent hain?
Nahi! Zero covariance sirf linear relationships ko rule out karta hai. Example: jab zero ke around symmetric ho toh zero covariance hai lekin complete dependence hai.
ka formula kya hai?
Sample covariance mein ki jagah kyun use karte hain?
Bessel's correction: sample means compute karte waqt hum ek degree of freedom khote hain, jisse estimator unbiased ho jaata hai.
ka matlab kya hai?
Perfect positive linear relationship: jab
ka matlab kya hai?
Perfect negative linear relationship: jab
Relationship strength compare karne ke liye correlation, covariance se better kyun hai?
Correlation scale-invariant (dimensionless) hai, jabki covariance aur ke units par depend karta hai.
Covariance ka ek ML application batao.
PCA (Principal Component Analysis) maximum variance ki directions dhundhne ke liye covariance matrix use karta hai.
kiske barabar hai?
(constants hat jaate hain; se scale karne par covariance scale hoti hai)

Connections

  • 1.3.01-Random-variables — covariance, variance ko RV pairs tak extend karta hai
  • 1.3.05-Expectation-and-variance — covariance expectation operator use karta hai
  • 1.3.08-Joint-and-marginal-distributions — covariance joint distributions se compute hota hai
  • 2.4.01-Principal-component-analysis — PCA covariance matrix ko diagonalize karta hai
  • 3.2.05-Linear-regression — correlation linear relationship ki strength measure karta hai
  • 3.2.06-Multicolinearity — high inter-feature correlation issues cause karta hai
  • 1.2.04-Independence — independent RVs ka zero covariance hota hai
  • 4.1.03-Feature-selection — feature ranking ke liye correlation-based methods

In concepts ko master karo, aur tum samajh jaoge ki variables kaise saath dance karte hain—theory se lekar ML applications tak.

Concept Map

measured by

defined as

expand and simplify

gives

has

implies zero

normalized by

yields

removed by

bounded

applied in

Joint variation of X and Y

Covariance

E of X minus muX times Y minus muY

E of XY minus E of X times E of Y

Independence

Sign gives direction

Units of X times Y

Correlation rho

Divide by sigmaX sigmaY

Range minus 1 to plus 1

Feature relationships PCA regression