DSPython Logo DSPython
Statistics for Data Science

Covariance

Direction first, strength later 🔄

1️⃣ What is Covariance?

Covariance tells us how two variables move together.

  • Both increase → Positive covariance
  • One up, one down → Negative covariance
  • No pattern → Zero covariance

👉 It answers:
“Direction same aa opposite aa?”

2️⃣ Real-World Examples

📚 Study & Marks
Positive covariance
🌡️ Temperature & Heater
Negative covariance
🎲 Shoe Size & IQ
Covariance ≈ 0

3️⃣ Intuition (Student Friendly)

Each data point checks:

  • X above average?
  • Y above average?

Same sign → positive
Opposite sign → negative

4️⃣ Visual 1: Covariance Direction

Positive Negative

5️⃣ Covariance vs Correlation (IMPORTANT)

Covariance Correlation
Shows direction only Shows direction + strength
Depends on scale Scale independent
Range is unlimited Always between -1 and +1
Hard to interpret alone Easy to interpret

👉 Correlation = Normalized Covariance

6️⃣ Visual 2: Same Relationship – Different Scale

Covariance changes with scale, correlation does not.

Small Scale Large Scale

7️⃣ Covariance Formula

Cov(X,Y) = Σ (Xi − X̄)(Yi − Ȳ) / (n − 1)

Interview Checkpoint 🎯 (5)

1. What does covariance tell?

Direction of relationship.

2. Why not use covariance alone?

Scale dependent.

3. Range of covariance?

Unlimited.

4. Relation between covariance & correlation?

Correlation is normalized covariance.

5. Where is covariance used?

PCA, finance, statistics.

🤖
DSPython AI Assistant
👋 Hi! I’m your AI assistant. Paste your code here, I will find bugs for you.