Foundations of Data Science 📂 Descriptive Statistics · 2 of 11 79 min read

What is Variance?

Variance measures how far each value in a dataset is spread from the mean. Learn what it is, how to calculate it, and why it matters in data science through real-world stories.

🌐
SectionSection第 01 节

The Story That Explains Varianceवह कहानी जो Variance समझाती है一个讲清方差的故事

Imagine two pizza delivery services in your city — QuickSlice and PizzaPal. Both say their average delivery time is 30 minutes. You order from both for ten days and write down the times.

अपने शहर की दो pizza delivery services की कल्पना करें — QuickSlice और PizzaPal. दोनों कहती हैं कि उनका औसत delivery time 30 minutes है। आप दस दिन दोनों से order करते हैं और समय लिखते हैं।

想象你所在城市有两家披萨外卖 —— QuickSlice 和 PizzaPal。两家都说平均送达时间是 30 分钟。 你连续十天从两家各点一次,并记下送达时间。

Dayदिन天QuickSlice (mins)QuickSlice (मिनट)QuickSlice(分钟)PizzaPal (mins)PizzaPal (मिनट)PizzaPal(分钟)
12910
23155
3308
42862
53215
63048
72920
83165
93012
10305
📊 SAME MEAN, VERY DIFFERENT SPREADवही MEAN, बहुत अलग फैलाव均值相同,离散程度天差地别
QuickSlice vs PizzaPal QuickSlice PizzaPal 0 10 20 30 40 50 60 70 both means = 30 minदोनों means = 30 min两者均值都是 30 分钟

Both have a mean of exactly 30 minutes. But QuickSlice always arrives within 28–32 minutes, while PizzaPal arrives anywhere from 5 to 65 minutes. The mean cannot show this difference. Variance can.

दोनों का mean ठीक 30 minutes है। पर QuickSlice हमेशा 28–32 मिनट में आता है, जबकि PizzaPal 5 से 65 मिनट में कभी भी आ सकता है। Mean यह अंतर नहीं दिखा सकता। Variance दिखा सकता है।

两家的均值都正好是 30 分钟。但 QuickSlice 总是在 28–32 分钟送到,而 PizzaPal 可能在 5 到 65 分钟之间的任何时间送到。 均值看不出这个差别。方差可以。

💡
What Variance Tells YouVariance क्या बताता है方差告诉你什么

Variance measures how far the values are from the mean, on average (using squared distances). A low variance means values stay close to the mean (like QuickSlice). A high variance means values are spread out (like PizzaPal). Same mean — completely different story.

Variance मापता है कि values औसतन mean से कितनी दूर हैं (squared दूरियों से)। कम variance मतलब values mean के पास रहती हैं (जैसे QuickSlice)। ज़्यादा variance मतलब values फैली हुई हैं (जैसे PizzaPal)। वही mean — पूरी तरह अलग कहानी।

方差衡量各个值平均离均值有多远(用距离的平方来算)。方差小,说明数值紧贴均值(像 QuickSlice);方差大,说明数值很分散(像 PizzaPal)。均值相同 —— 故事却完全不同。


SectionSection第 02 节

Variance in Pictures — Understand It Before the Formulaतस्वीरों में Variance — Formula से पहले समझें图解方差 — 先看懂,再看公式

🖼️ TWO PICTURES TO REMEMBERयाद रखने वाली दो तस्वीरें记住这两幅图
Variance in pictures LOW VARIANCEकम VARIANCE方差小 darts close to the centredarts केंद्र के पास飞镖都靠近中心 HIGH VARIANCEज़्यादा VARIANCE方差大 same centre, darts everywhereवही केंद्र, darts हर जगह中心相同,飞镖到处都是 VARIANCE = AVERAGE SQUAREVARIANCE = औसत SQUARE方差 = 平均正方形面积 mean = 5 side = distance from the meanभुजा = mean से दूरी边长 = 到均值的距离 variance ≈ average area of the squaresvariance ≈ squares का औसत क्षेत्रफल方差 ≈ 这些正方形的平均面积

Darts: both players aim at the centre and both are "right on average", but one is far more consistent. Variance measures that consistency.
Squares: draw a square from each point to the mean. Its side is the distance, its area is the squared distance. Variance is (roughly) the average area of these squares — big squares mean big spread.

Darts: दोनों खिलाड़ी केंद्र पर निशाना लगाते हैं और दोनों "औसतन सही" हैं, पर एक कहीं ज़्यादा consistent है। Variance इसी consistency को मापता है।
Squares: हर point से mean तक एक square बनाएँ। उसकी भुजा दूरी है, उसका क्षेत्रफल squared दूरी है। Variance (लगभग) इन squares का औसत क्षेत्रफल है — बड़े squares मतलब ज़्यादा फैलाव।

飞镖:两位选手都瞄准中心,平均来看都“打中了”,但其中一位稳定得多。方差衡量的正是这种稳定性。
正方形:从每个点到均值画一个正方形,边长是距离,面积就是距离的平方。方差(大致)就是这些正方形的平均面积 —— 正方形越大,越分散。

LIVELIVE互动See Variance as Squares — Drag the PointsVariance को Squares की तरह देखें — Points खींचें把方差看成正方形 — 拖动数据点

Each delivery time has a square to the green mean line. Switch between QuickSlice and PizzaPal, drag any dot, and switch the divisor between n − 1 (sample) and n (population).

हर delivery time से हरी mean line तक एक square है। QuickSlice और PizzaPal के बीच बदलें, कोई भी dot खींचें, और भाजक को n − 1 (sample) और n (population) के बीच बदलें।

每个送达时间都有一个连到绿色均值线的正方形。在 QuickSlice 和 PizzaPal 之间切换,拖动任意一个点,并在 n − 1(样本)和 n(总体)之间切换除数。

Divide by

Variance (min²)Variance (min²)方差(分钟²)
—
Std. deviation (min)Std. deviation (min)标准差(分钟)
—


SectionSection第 03 节

The FormulaFormula公式

Population VariancePopulation Variance总体方差
σ² = Σ(x − μ)² / N
Use when you have every data point of the whole population.
जब पूरी population का हर data point आपके पास हो।
拥有整个总体的每一个数据点时使用。
Sample VarianceSample Variance样本方差
s² = Σ(x − x̄)² / (n − 1)
Use when your data is a sample from a larger population (the usual case).
जब आपका data किसी बड़ी population का sample हो (आम स्थिति)।
数据是从更大总体中抽取的样本时使用(最常见的情况)。
📐
Why (n − 1) and not n?(n − 1) क्यों, n क्यों नहीं?为什么除以 (n − 1) 而不是 n?

This is Bessel's correction. In a sample we measure distances from the sample mean, and the sample mean is always as close as possible to its own data. So the squared distances come out a little too small, and dividing by n underestimates the population variance. Dividing by (n − 1) fixes this on average, which is why s² is called an unbiased estimator. The simulator below proves it with thousands of random samples.

इसे Bessel's correction कहते हैं। Sample में हम दूरियाँ sample mean से मापते हैं, और sample mean हमेशा अपने data के जितना हो सके पास होता है। इसलिए squared दूरियाँ थोड़ी छोटी आती हैं, और n से भाग देने पर population variance कम आँका जाता है। (n − 1) से भाग देने पर यह औसतन ठीक हो जाता है, इसीलिए s² को unbiased estimator कहते हैं। नीचे का simulator हज़ारों random samples से इसे साबित करता है।

这叫作 Bessel 校正。在样本中,我们是从样本均值出发量距离的,而样本均值总是尽可能贴近它自己的数据。所以算出来的平方距离会偏小一点,除以 n 会低估总体方差。 除以 (n − 1) 在平均意义上修正了这个偏差,所以 s² 被称为无偏估计量。下面的模拟器用成千上万个随机样本来证明这一点。

LIVELIVE互动Prove Bessel's Correction With Random SamplesRandom Samples से Bessel's Correction साबित करें用随机样本证明 Bessel 校正

A population with true variance 100. Draw samples of size n and compute the variance two ways. Watch the running averages: dividing by n stays too low, dividing by n − 1 lands on 100. Try n = 2 and n = 20.

असली variance 100 वाली एक population. Size n के samples निकालें और variance दो तरीकों से निकालें। चलते औसत देखें: n से भाग देने वाला बहुत नीचे रहता है, n − 1 वाला 100 पर पहुँचता है। n = 2 और n = 20 आज़माएँ।

一个真实方差为 100 的总体。抽取大小为 n 的样本,用两种方法计算方差。观察累计平均:除以 n 的一直偏低,除以 n − 1 的正好落在 100。试试 n = 2 和 n = 20。

Average, ÷ nऔसत, ÷ n平均值,÷ n
—
Average, ÷ (n − 1)औसत, ÷ (n − 1)平均值,÷ (n − 1)
—

import numpy as np

# Why divide by n - 1? Draw many small samples from a population with a known variance.
rng = np.random.default_rng(42)
population = rng.normal(30, 10, 1_000_000)      # true variance ≈ 100
print(f"True population variance: {population.var():.1f}")

samples = rng.choice(population, size=(100_000, 5))   # 100,000 samples of size n = 5
print(f"Average of variances dividing by n    : {samples.var(axis=1, ddof=0).mean():.1f}")
print(f"Average of variances dividing by n - 1: {samples.var(axis=1, ddof=1).mean():.1f}")
OUTPUT
True population variance: 100.1 Average of variances dividing by n : 80.0 Average of variances dividing by n - 1: 100.0

With n = 5, dividing by n gives on average 80 instead of 100 — exactly (n − 1)/n = 4/5 of the truth. Dividing by n − 1 gives 100. The bigger the sample, the smaller this gap.

n = 5 पर, n से भाग देने पर औसतन 100 की जगह 80 मिलता है — ठीक (n − 1)/n = 4/5 हिस्सा। n − 1 से भाग देने पर 100 मिलता है। Sample जितना बड़ा, यह gap उतना छोटा।

n = 5 时,除以 n 平均得到 80 而不是 100 —— 正好是真值的 (n − 1)/n = 4/5。除以 n − 1 得到 100。样本越大,这个差距越小。


SectionSection第 04 节

Step-by-Step CalculationStep-by-Step गणना分步计算

Let us calculate the variance for QuickSlice: [29, 31, 30, 28, 32, 30, 29, 31, 30, 30] — mean = 30

चलिए QuickSlice का variance निकालें: [29, 31, 30, 28, 32, 30, 29, 31, 30, 30] — mean = 30

我们来计算 QuickSlice 的方差:[29, 31, 30, 28, 32, 30, 29, 31, 30, 30] —— 均值 = 30

🧮 QuickSlice VarianceQuickSlice VarianceQuickSlice 的方差
Step 1
Subtract the mean from each value.
(29−30)=−1   (31−30)=1   (30−30)=0   (28−30)=−2   (32−30)=2   (30−30)=0   (29−30)=−1   (31−30)=1   (30−30)=0   (30−30)=0
Check: these always add up to 0.
हर value से mean घटाएँ।
(29−30)=−1   (31−30)=1   (30−30)=0   (28−30)=−2   (32−30)=2   (30−30)=0   (29−30)=−1   (31−30)=1   (30−30)=0   (30−30)=0
जाँच: इनका जोड़ हमेशा 0 होता है।
每个值减去均值。
(29−30)=−1   (31−30)=1   (30−30)=0   (28−30)=−2   (32−30)=2   (30−30)=0   (29−30)=−1   (31−30)=1   (30−30)=0   (30−30)=0
检查:它们的和永远是 0。
Step 2
Square each difference (this removes the minus signs) and add them up.
1 + 1 + 0 + 4 + 4 + 0 + 1 + 1 + 0 + 0 = 12
हर अंतर का square करें (इससे minus हट जाते हैं) और जोड़ें।
1 + 1 + 0 + 4 + 4 + 0 + 1 + 1 + 0 + 0 = 12
把每个差值平方(这样负号就没了),再相加。
1 + 1 + 0 + 4 + 4 + 0 + 1 + 1 + 0 + 0 = 12
Step 3
Divide by (n − 1) — sample variance.
12 / (10 − 1) = 12 / 9 = 1.33 min²
(n − 1) से भाग दें — sample variance.
12 / (10 − 1) = 12 / 9 = 1.33 min²
除以 (n − 1) —— 样本方差。
12 / (10 − 1) = 12 / 9 = 1.33 分钟²

Now PizzaPal: [10, 55, 8, 62, 15, 48, 20, 65, 12, 5] — mean = 30

अब PizzaPal: [10, 55, 8, 62, 15, 48, 20, 65, 12, 5] — mean = 30

再看 PizzaPal:[10, 55, 8, 62, 15, 48, 20, 65, 12, 5] —— 均值 = 30

🧮 PizzaPal VariancePizzaPal VariancePizzaPal 的方差
Step 1
Subtract the mean from each value.
(10−30)=−20   (55−30)=25   (8−30)=−22   (62−30)=32   (15−30)=−15   (48−30)=18   (20−30)=−10   (65−30)=35   (12−30)=−18   (5−30)=−25
हर value से mean घटाएँ।
(10−30)=−20   (55−30)=25   (8−30)=−22   (62−30)=32   (15−30)=−15   (48−30)=18   (20−30)=−10   (65−30)=35   (12−30)=−18   (5−30)=−25
每个值减去均值。
(10−30)=−20   (55−30)=25   (8−30)=−22   (62−30)=32   (15−30)=−15   (48−30)=18   (20−30)=−10   (65−30)=35   (12−30)=−18   (5−30)=−25
Step 2
Square each difference and add.
400 + 625 + 484 + 1024 + 225 + 324 + 100 + 1225 + 324 + 625 = 5356
हर अंतर का square करें और जोड़ें।
400 + 625 + 484 + 1024 + 225 + 324 + 100 + 1225 + 324 + 625 = 5356
把每个差值平方后相加。
400 + 625 + 484 + 1024 + 225 + 324 + 100 + 1225 + 324 + 625 = 5356
Step 3
Divide by (n − 1).
5356 / 9 = 595.11 min²
(n − 1) से भाग दें।
5356 / 9 = 595.11 min²
除以 (n − 1)。
5356 / 9 = 595.11 分钟²
🧮
Resultनतीजा结果

QuickSlice variance = 1.33 min²  |  PizzaPal variance = 595.11 min²
Same mean, but PizzaPal's variance is about 446 times larger. Now you have proof — not just a feeling — that PizzaPal is very unpredictable.

QuickSlice variance = 1.33 min²  |  PizzaPal variance = 595.11 min²
वही mean, पर PizzaPal का variance लगभग 446 गुना बड़ा है। अब आपके पास सबूत है — सिर्फ़ एहसास नहीं — कि PizzaPal बहुत अनिश्चित है।

QuickSlice 方差 = 1.33 分钟²  |  PizzaPal 方差 = 595.11 分钟²
均值相同,但 PizzaPal 的方差约是前者的 446 倍。现在你有了证据 —— 而不只是感觉 —— 证明 PizzaPal 非常不靠谱。


SectionSection第 05 节

Python ImplementationPython ImplementationPython 实现

Manual calculationहाथ से गणना手动计算

quickslice = [29, 31, 30, 28, 32, 30, 29, 31, 30, 30]
pizzapal   = [10, 55,  8, 62, 15, 48, 20, 65, 12,  5]

def sample_variance(data):
    n    = len(data)
    mean = sum(data) / n
    return sum((x - mean) ** 2 for x in data) / (n - 1)

print(f"QuickSlice variance: {sample_variance(quickslice):.2f}")
print(f"PizzaPal variance:   {sample_variance(pizzapal):.2f}")
print(f"PizzaPal is {sample_variance(pizzapal) / sample_variance(quickslice):.0f}x more variable")
OUTPUT
QuickSlice variance: 1.33 PizzaPal variance: 595.11 PizzaPal is 446x more variable

Using the statistics modulestatistics module से使用 statistics 模块

import statistics

quickslice = [29, 31, 30, 28, 32, 30, 29, 31, 30, 30]
pizzapal   = [10, 55,  8, 62, 15, 48, 20, 65, 12,  5]

# Sample variance (divides by n - 1)
print(statistics.variance(quickslice))
print(statistics.variance(pizzapal))

# Population variance (divides by n)
print(statistics.pvariance(quickslice))
print(statistics.pvariance(pizzapal))
OUTPUT
1.3333333333333333 595.1111111111111 1.2 535.6

Using NumPy and pandasNumPy और pandas से使用 NumPy 和 pandas

import numpy as np
import pandas as pd

pizzapal   = [10, 55,  8, 62, 15, 48, 20, 65, 12,  5]

# NumPy: ddof=0 (population) is the DEFAULT
print(np.var(pizzapal))            # divides by n
print(np.var(pizzapal, ddof=1))    # divides by n - 1

# pandas: ddof=1 (sample) is the DEFAULT — the opposite of NumPy!
s = pd.Series(pizzapal)
print(s.var())                     # divides by n - 1
print(s.var(ddof=0))               # divides by n
OUTPUT
535.6 595.1111111111111 595.1111111111111 535.6
⚠️
NumPy and pandas Disagree by DefaultNumPy और pandas के default अलग हैंNumPy 和 pandas 的默认值不一样

np.var() uses ddof=0 by default (population variance), but pandas .var() uses ddof=1 (sample variance). The same data gives 535.6 in NumPy and 595.11 in pandas. Always write ddof explicitly — this small detail causes many real bugs.

np.var() default में ddof=0 (population variance) इस्तेमाल करता है, पर pandas .var() ddof=1 (sample variance)। वही data NumPy में 535.6 और pandas में 595.11 देता है। हमेशा ddof साफ़-साफ़ लिखें — यह छोटी बात बहुत सारे असली bugs की वजह बनती है।

np.var() 默认 ddof=0(总体方差),而 pandas 的 .var() 默认 ddof=1(样本方差)。同样的数据,NumPy 给出 535.6,pandas 给出 595.11。 一定要显式写出 ddof —— 这个小细节导致了很多真实的 bug。


SectionSection第 06 节

Two Things to Watch: Squared Units and Outliersदो बातों का ध्यान रखें: Squared Units और Outliers需要注意的两件事:平方单位与离群点

Variance is powerful, but its unit is squared. If your data is in minutes, variance is in minutes squared, which is hard to picture.

Variance ताक़तवर है, पर इसकी unit squared होती है। अगर data minutes में है, तो variance minutes squared में होगा, जिसकी कल्पना करना मुश्किल है।

方差很有用,但它的单位是平方。数据以分钟为单位,方差的单位就是平方分钟,很难想象。

DataData数据UnitUnit单位Variance unitVariance unit方差单位Easy to read?पढ़ना आसान?容易理解吗?
Delivery timesDelivery times送达时间minutesminutes分钟minutes²minutes²分钟²Hard to interpretसमझना मुश्किल难以理解
Heightsऊँचाई身高cmcm²Hard to interpretसमझना मुश्किल难以理解
Pricesदाम价格₹₹²Hard to interpretसमझना मुश्किल难以理解
Temperaturesतापमान温度°C°C²Hard to interpretसमझना मुश्किल难以理解
LIVELIVE互动Shift and Scale the DataData को खिसकाएँ और बड़ा-छोटा करें平移和缩放数据

Multiply every value by k (for example, minutes → seconds is k = 60) and add a constant c. The shaded band is mean ± one standard deviation.

हर value को k से गुणा करें (जैसे minutes → seconds में k = 60) और एक constant c जोड़ें। छायांकित पट्टी mean ± एक standard deviation है।

把每个值乘以 k(例如分钟 → 秒就是 k = 60),再加上常数 c。阴影带表示均值 ± 一个标准差。

Scaling ruleScaling नियम缩放规则
Var(kX + c) = k² · Var(X)
Multiply by k → variance × k². Add c → variance unchanged.
k से गुणा → variance × k². c जोड़ें → variance वही।
乘以 k → 方差 × k²。加上 c → 方差不变。
Standard deviationStandard deviation标准差
SD = √Variance
Back in the original unit: minutes, cm, ₹. SD(kX + c) = |k| · SD(X).
मूल unit में वापस: minutes, cm, ₹. SD(kX + c) = |k| · SD(X).
回到原始单位:分钟、厘米、₹。SD(kX + c) = |k| · SD(X)。
🎯
Solution: Standard Deviationहल: Standard Deviation解决办法:标准差

Taking the square root of the variance gives the standard deviation, which is in the same unit as the data. QuickSlice: √1.33 ≈ 1.15 minutes; PizzaPal: √595.11 ≈ 24.4 minutes — easy to understand. That is why the standard deviation is used to explain spread, while variance is used inside formulas and models. The next tutorial covers standard deviation in full.

Variance का square root लेने से standard deviation मिलता है, जो data की ही unit में होता है। QuickSlice: √1.33 ≈ 1.15 मिनट; PizzaPal: √595.11 ≈ 24.4 मिनट — समझना आसान। इसीलिए फैलाव समझाने के लिए standard deviation इस्तेमाल होता है, जबकि variance formulas और models के अंदर। अगला tutorial standard deviation को पूरा cover करता है।

对方差开平方就得到标准差,单位和数据相同。QuickSlice:√1.33 ≈ 1.15 分钟;PizzaPal:√595.11 ≈ 24.4 分钟 —— 一目了然。 所以解释离散程度时用标准差,而在公式和模型内部用方差。下一篇教程会完整讲解标准差。

Outliers: one value can take overOutliers: एक value हावी हो सकती है离群点:一个值就能主导一切

LIVELIVE互动Move One Delivery Far Awayएक Delivery को बहुत दूर ले जाएँ把一次配送拉到很远

Nine QuickSlice deliveries stay fixed (grey). Move the last one with the slider. The curve shows the variance for every position of that one value — it grows with the square of the distance.

QuickSlice की नौ deliveries अपनी जगह रहती हैं (स्लेटी)। आख़िरी को slider से खिसकाएँ। Curve उस एक value की हर जगह के लिए variance दिखाता है — यह दूरी के square के साथ बढ़ता है।

QuickSlice 的九次配送固定不动(灰色),用滑块移动最后一次。曲线显示这一个值处于每个位置时的方差 —— 它随距离的平方增长。

Variance (min²)Variance (min²)方差(分钟²)
—
Std. deviation (min)Std. deviation (min)标准差(分钟)
—

import numpy as np

data = [29, 31, 30, 28, 32, 30, 29, 31, 30, 30]   # QuickSlice
print(f"Original          : var = {np.var(data, ddof=1):8.2f}   sd = {np.std(data, ddof=1):6.2f}")

# One late delivery: 30 minutes becomes 90 minutes
late = data[:-1] + [90]
print(f"One late delivery : var = {np.var(late, ddof=1):8.2f}   sd = {np.std(late, ddof=1):6.2f}")

# Units: minutes → seconds multiplies every value by 60
secs = [x * 60 for x in data]
print(f"In seconds        : var = {np.var(secs, ddof=1):8.2f}   sd = {np.std(secs, ddof=1):6.2f}")

# Adding a constant (+5 minutes to every order) does not change the spread
plus5 = [x + 5 for x in data]
print(f"Every order +5 min: var = {np.var(plus5, ddof=1):8.2f}   sd = {np.std(plus5, ddof=1):6.2f}")
OUTPUT
Original : var = 1.33 sd = 1.15 One late delivery : var = 361.33 sd = 19.01 In seconds : var = 4800.00 sd = 69.28 Every order +5 min: var = 1.33 sd = 1.15

One late delivery (90 minutes instead of 30) raises the variance from 1.33 to 361 — about 270 times. Converting minutes to seconds multiplies the variance by 60² = 3,600 (1.33 → 4,800), while adding 5 minutes to every order changes nothing.

एक देर वाली delivery (30 की जगह 90 मिनट) variance को 1.33 से 361 कर देती है — लगभग 270 गुना। Minutes को seconds में बदलने से variance 60² = 3,600 से गुणा हो जाता है (1.33 → 4,800), जबकि हर order में 5 मिनट जोड़ने से कुछ नहीं बदलता।

一次迟到的配送(90 分钟而不是 30 分钟)把方差从 1.33 推到 361 —— 约 270 倍。把分钟换成秒,方差乘以 60² = 3,600(1.33 → 4,800);而每单都加 5 分钟,方差完全不变。


SectionSection第 07 节

Where Variance Is Used in Data ScienceData Science में Variance कहाँ इस्तेमाल होता है方差在数据科学中的应用

PCAPCAPCA(主成分分析)
📊
  • Finds the directions of maximum varianceसबसे ज़्यादा variance वाली दिशाएँ खोजता है找出方差最大的方向
  • Reduces the number of dimensionsDimensions की संख्या घटाता है减少维度
  • Keeps the components that explain most varianceसबसे ज़्यादा variance समझाने वाले components रखता है保留解释方差最多的成分
ANOVAANOVAANOVA(方差分析)
📐
  • Compares the variance between groups with the variance within groupsGroups के बीच के variance की तुलना groups के अंदर के variance से करता है比较组间方差与组内方差
  • Tests whether group means really differजाँचता है कि groups के means सच में अलग हैं या नहीं检验各组均值是否真有差异
  • Used for experiments with 3+ versions3+ versions वाले experiments में इस्तेमाल用于 3 个及以上版本的实验
FinanceFinance金融
📈
  • Variance of returns = investment riskReturns का variance = निवेश का जोखिम收益率的方差 = 投资风险
  • Portfolio optimisation (mean–variance)Portfolio optimisation (mean–variance)投资组合优化(均值—方差)
  • Volatility analysisVolatility analysis波动率分析
LIVELIVE互动Same Average Return, Different Varianceवही औसत Return, अलग Variance平均收益相同,方差不同

₹1,00,000 invested in two funds. Both earn 1% per month on average. Fund A has a monthly standard deviation of 2%; set Fund B with the slider. Five random futures for each fund.

दो funds में ₹1,00,000 लगाए गए। दोनों औसतन हर महीने 1% कमाते हैं। Fund A का monthly standard deviation 2% है; Fund B का slider से set करें। हर fund के पाँच random भविष्य।

₹1,00,000 分别投入两只基金。两只基金平均每月都赚 1%。基金 A 的月标准差是 2%,基金 B 用滑块设置。每只基金模拟五种随机的未来。


SectionSection第 08 节

Golden RulesGolden Rules黄金法则

🎯 Variance — Key RulesVariance — मुख्य नियम方差 — 关键规则
1
Variance is always zero or positive, because the differences are squared before they are added. A variance of zero means every value is the same.
Variance हमेशा शून्य या positive होता है, क्योंकि अंतर जोड़ने से पहले square किए जाते हैं। शून्य variance मतलब हर value एक जैसी है।
方差总是零或正数,因为差值在相加之前都平方了。方差为零意味着所有值都相同。
2
Use sample variance (n − 1) when your data is a sample. Use population variance (n) only when you have the complete population — which is rare.
जब data एक sample हो तो sample variance (n − 1) इस्तेमाल करें। Population variance (n) तभी जब पूरी population हो — जो कम होता है।
数据是样本时,用样本方差(n − 1)。只有拥有完整总体时才用总体方差(n)—— 这很少见。
3
Always write ddof in code: NumPy defaults to 0, pandas to 1.
Code में हमेशा ddof लिखें: NumPy का default 0 है, pandas का 1.
代码里一定要写明 ddof:NumPy 默认 0,pandas 默认 1。
4
Variance is very sensitive to outliers. Because differences are squared, one extreme value can blow it up. Check for outliers (box plot, IQR) before you trust it.
Variance outliers से बहुत प्रभावित होता है। अंतर square होने से एक extreme value इसे बहुत बढ़ा सकती है। भरोसा करने से पहले outliers जाँचें (box plot, IQR)।
方差对离群点极其敏感。因为差值要平方,一个极端值就能让它暴涨。相信它之前先检查离群点(箱线图、IQR)。
5
For explaining spread, use the standard deviation (same unit as the data). For maths and models, use variance — for example, the variances of independent quantities simply add up.
फैलाव समझाने के लिए standard deviation इस्तेमाल करें (data की ही unit)। गणित और models के लिए variance — जैसे स्वतंत्र quantities के variances सीधे जुड़ जाते हैं।
解释离散程度时用标准差(单位与数据相同)。数学和模型里用方差 —— 比如相互独立的量,其方差可以直接相加。