TGViewer
Data Science & Machine Learning Data Science & Machine Learning @datasciencefun ยท 77.8K subscribers
Post #4496 1.91K
๐Ÿš€ Data Science Roadmap 2026

๐Ÿ“˜ Phase 2: Mathematics for Data Science

๐Ÿ“– Topic 3: Variance & Standard Deviation

Welcome back! ๐Ÿ‘‹

In the previous lesson, you learned about Mean, Median, and Mode, which help us find the center of a dataset.

But knowing the average alone is not enough.

Imagine these two datasets:

Dataset A

40, 45, 50, 55, 60

Dataset B

10, 20, 50, 80, 90

Both datasets have the same mean (50), but they are very different.

โ€ข Dataset A has values close to the mean.

โ€ข Dataset B has values spread far away from the mean.

To measure this spread, we use Variance and Standard Deviation.

These are among the most important statistical concepts in Data Science and Machine Learning.

๐Ÿ”น 1. What is Variance?

Variance measures how far each value is from the mean.

โ€ข Small variance โ†’ Data points are close together.

โ€ข Large variance โ†’ Data points are widely spread.

Formula (Population Variance)

Variance = ฮฃ(x โˆ’ Mean)ยฒ / N

Where:

โ€ข ฮฃ = Sum

โ€ข x = Each data point

โ€ข Mean = Average

โ€ข N = Total number of observations

๐Ÿ”น 2. Example of Variance

Dataset: 10, 20, 30

Step 1: Find the Mean

(10 + 20 + 30) / 3 = 20

Step 2: Find the Difference from the Mean

10 โˆ’ 20 = -10

20 โˆ’ 20 = 0

30 โˆ’ 20 = 10

Step 3: Square the Differences

100, 0, 100

Step 4: Calculate Variance

(100 + 0 + 100) / 3 = 66.67

๐Ÿ”น 3. What is Standard Deviation? โญ

Standard Deviation (SD) is simply the square root of the variance.

Formula

Standard Deviation = โˆšVariance

Using the previous example:

Variance = 66.67

SD = โˆš66.67 โ‰ˆ 8.16

๐Ÿ”น 4. Why Standard Deviation is Preferred?

Variance is measured in squared units, making it harder to interpret.

Standard Deviation is measured in the same units as the original data, making it easier to understand.

Example:

If salaries are measured in rupees:

โ€ข Variance โ†’ Rupeesยฒ โŒ

โ€ข Standard Deviation โ†’ Rupees โœ…

๐Ÿ”น 5. Python Example

Using the "statistics" module:

import statistics

numbers = [10, 20, 30]

print(statistics.pvariance(numbers))
print(statistics.pstdev(numbers))
  • โค 5
  • ๐Ÿ‘ 2
More from @datasciencefun
  1. Oct 7, 2026ORDER BY salary DESC LIMIT 5; Mistake 3 โ€” Forgetting that LIMIT applies after sorting Forโ€ฆ
  2. Oct 7, 2026๐Ÿš€ Data Science Roadmap 2026 ๐Ÿ“ Phase 3: SQL for Data Science ๐Ÿ“– Topic 4 โ€” LIMIT LIMIT isโ€ฆ
  3. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  4. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  5. Oct 2, 2026Data Visualisation tips for beginners
  6. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’