The Doctor, the Investor & the Factory ManagerDoctor, Investor और Factory Manager医生、投资者与工厂经理
Three professionals sit around a table. Each holds a dataset and a single number: a standard deviation.
तीन professionals एक table पर बैठे हैं। हर एक के पास एक dataset और एक संख्या है: standard deviation.
三位专业人士围坐在桌旁,每人手里都有一个数据集和一个数字:标准差。
The doctor says: "My patients' blood pressure has a standard deviation of 12 mmHg." The investor says: "My portfolio's monthly value has a standard deviation of ₹12,000." The factory manager says: "My machine makes bolts with a standard deviation of 0.12 mm."
Doctor कहते हैं: "मेरे patients के blood pressure का standard deviation 12 mmHg है।" Investor कहते हैं: "मेरे portfolio की monthly value का standard deviation ₹12,000 है।" Factory manager कहते हैं: "मेरी machine जो bolts बनाती है, उनका standard deviation 0.12 mm है।"
医生说:“我的病人血压的标准差是 12 mmHg。”投资者说:“我的投资组合月度价值的标准差是 ₹12,000。”工厂经理说:“我的机器生产的螺栓,标准差是 0.12 mm。”
Who has the most variable data? You cannot tell. The units are different — mmHg, rupees, millimetres — and so are the typical sizes: about 120 mmHg, about ₹80,000 and about 10 mm. Comparing these SDs directly is like comparing the weight of an apple, the length of a road and the temperature of a room. The numbers mean nothing without their scale.
किसका data सबसे ज़्यादा बदलता है? बताया नहीं जा सकता। Units अलग हैं — mmHg, रुपये, millimetre — और आम आकार भी: लगभग 120 mmHg, लगभग ₹80,000 और लगभग 10 mm. इन SDs की सीधी तुलना ऐसी है जैसे सेब का वज़न, सड़क की लंबाई और कमरे के तापमान की तुलना। अपने scale के बिना ये संख्याएँ बेमतलब हैं।
谁的数据波动最大?说不清。单位不同 —— mmHg、卢比、毫米 —— 典型大小也不同:约 120 mmHg、约 ₹80,000 和约 10 mm。直接比较这些标准差,就像比较一个苹果的重量、一条路的长度和一个房间的温度。离开各自的尺度,这些数字毫无意义。
The coefficient of variation (CV), also called the relative standard deviation (RSD), expresses the standard deviation as a percentage of the mean. The units cancel out, so the result can be compared across datasets, units and fields. Now the three can finally compare their variability: 10% for blood pressure, 15% for the portfolio, 1.2% for the bolts.
Coefficient of variation (CV), जिसे relative standard deviation (RSD) भी कहते हैं, standard deviation को mean के percentage के रूप में बताता है। Units कट जाती हैं, इसलिए नतीजे की तुलना datasets, units और क्षेत्रों के बीच हो सकती है। अब तीनों आख़िरकार अपना फैलाव तुलना कर सकते हैं: blood pressure 10%, portfolio 15%, bolts 1.2%.
变异系数(CV),也叫相对标准差(RSD),把标准差表示为均值的百分比。单位相互抵消,结果可以跨数据集、跨单位、跨领域比较。现在三人终于能比较各自的波动了:血压 10%,投资组合 15%,螺栓 1.2%。
CV is used everywhere — comparing the consistency of machines, the risk of investments, the precision of laboratory tests and the reliability of rainfall. It is one of the most practically useful statistics in a data scientist's toolkit.
CV हर जगह इस्तेमाल होता है — machines की consistency, investments का risk, lab tests की precision और बारिश की विश्वसनीयता की तुलना में। यह data scientist के toolkit के सबसे काम के statistics में से एक है।
CV 用途广泛 —— 比较机器的稳定性、投资的风险、实验室检测的精密度、降雨的可靠性。它是数据科学家工具箱里最实用的统计量之一。
CV in Pictures — Understand Before the Mathsतस्वीरों में CV — गणित से पहले समझें图解 CV — 先理解,再算数
Two datasets have exactly the same standard deviation, σ = 10. Dataset A has mean 20; dataset B has mean 200. On one shared ruler they look equally spread. But measure each one against its own size — a ruler from 0 to twice its mean — and the difference jumps out. That relative width is the CV.
दो datasets का standard deviation बिल्कुल एक है, σ = 10. Dataset A का mean 20 है; dataset B का 200. एक ही ruler पर दोनों बराबर फैले दिखते हैं। पर हर एक को उसके अपने आकार से नापें — 0 से उसके mean के दोगुने तक का ruler — और फ़र्क़ साफ़ दिखता है। यही relative चौड़ाई CV है।
两个数据集的标准差完全相同,σ = 10。数据集 A 的均值是 20,B 是 200。在同一把尺子上,它们看起来一样分散。但用各自的大小去量 —— 一把从 0 到自身均值两倍的尺子 —— 差别立刻显现。这个相对宽度就是 CV。
Move the mean and the standard deviation. The axis always runs from 0 to twice the mean, so the width of the bell on screen is the CV. Try A and B, then make the SD bigger than half the mean.
Mean और standard deviation बदलें। Axis हमेशा 0 से mean के दोगुने तक चलता है, इसलिए screen पर bell की चौड़ाई ही CV है। A और B आज़माएँ, फिर SD को mean के आधे से बड़ा करें।
调整均值和标准差。横轴始终从 0 到均值的两倍,所以屏幕上钟形的宽度就是 CV。试试 A 和 B,再把标准差调到超过均值的一半。
First compare the raw standard deviations, then switch to CV.
पहले कच्चे standard deviations की तुलना करें, फिर CV पर जाएँ।
先比较原始标准差,再切换到 CV。
What CV Measures — The Core IdeaCV क्या मापता है — मूल विचारCV 衡量什么 — 核心思想
Standard deviation tells you the absolute spread of data. CV tells you the relative spread — how big the variation is compared with the average value. Think of it as asking: "For every unit of mean, how much variation do I have?"
Standard deviation data का absolute फैलाव बताता है। CV relative फैलाव बताता है — बदलाव औसत value की तुलना में कितना बड़ा है। इसे ऐसे सोचें: "Mean की हर unit पर मेरे पास कितना बदलाव है?"
标准差告诉你数据的绝对离散程度;CV 告诉你相对离散程度 —— 波动相对于平均值有多大。可以理解为在问:“每一个单位的均值,伴随多少波动?”
- Very consistent dataबहुत एक जैसा data数据非常稳定
- Spread is small vs the meanMean की तुलना में फैलाव छोटा离散程度相对均值很小
- High precision / reliabilityऊँची precision / भरोसा高精密度 / 高可靠性
- e.g. factory bolts, lab testsजैसे factory bolts, lab tests例如工厂螺栓、实验室检测
- Noticeable variabilityध्यान देने लायक बदलाव波动明显
- Common in biology and businessBiology और business में आम在生物和商业数据中常见
- Judge it in contextसंदर्भ में परखें需结合背景判断
- e.g. monthly sales, crop yieldsजैसे monthly sales, फ़सल की पैदावार例如月销售额、作物产量
- Highly variable / riskyबहुत बदलने वाला / जोखिम भरा波动大 / 风险高
- Spread is large vs the meanMean की तुलना में फैलाव बड़ा离散程度相对均值很大
- Often skewed dataअक्सर skewed data通常是偏斜数据
- e.g. incomes, purchase amountsजैसे incomes, purchase amounts例如收入、消费金额
These cut-offs are rules of thumb. What counts as "low" depends on the field: 3% is poor for a precision instrument, while 30% is excellent for daily sales of a small shop. Adult heights have a CV of only about 4–5%, so they belong in the low group.
ये सीमाएँ अंगूठा-नियम हैं। "कम" क्या है, यह क्षेत्र पर निर्भर है: precision instrument के लिए 3% ख़राब है, जबकि छोटी दुकान की daily sales के लिए 30% बहुत अच्छा। वयस्कों की height का CV सिर्फ़ लगभग 4–5% है, इसलिए वह कम वाले group में आती है।
这些分界只是经验法则。什么算“低”取决于领域:对精密仪器,3% 已算差;而对小店的日销售额,30% 已经很好。成年人身高的 CV 只有约 4–5%,属于低 CV 一组。
Dividing by the mean only makes sense when zero means "none of it" — ratio-scale data such as weight, income, length or time — and when all values are positive. With a mean near zero, CV becomes huge; with a negative mean, it becomes negative. Never use CV for temperatures in °C or °F, or for data that can naturally be negative (profits, returns, changes). See Section 8.
Mean से भाग देने का मतलब तभी बनता है जब zero का मतलब "बिल्कुल नहीं" हो — weight, income, length या time जैसा ratio-scale data — और सारी values positive हों। Mean zero के पास हो तो CV बहुत बड़ा हो जाता है; negative mean पर negative. °C या °F के तापमान, या स्वाभाविक रूप से negative हो सकने वाले data (profits, returns, बदलाव) पर CV कभी न लगाएँ। Section 8 देखें।
只有当零表示“完全没有”—— 即重量、收入、长度或时间这类定比数据 —— 且所有值都为正时,除以均值才有意义。均值接近零时 CV 会变得巨大;均值为负时 CV 变成负数。永远不要对摄氏或华氏温度、或本身就可能为负的数据(利润、收益、变化量)使用 CV。见第 8 节。
The FormulaFormula公式
The formula is simple. You already know both parts — CV just divides one by the other.
Formula आसान है। आप दोनों हिस्से पहले से जानते हैं — CV बस एक को दूसरे से भाग देता है।
公式很简单。两个组成部分你都已经认识 —— CV 只是用一个除以另一个。
A CV of 8% means the typical distance from the mean is only 8% of the mean itself — very consistent.
A CV of 80% means the typical distance is 80% of the mean — the values are all over the place compared with their centre.
Lower CV = more consistent. Higher CV = more variable.
8% CV का मतलब है कि mean से आम दूरी mean का सिर्फ़ 8% है — बहुत एक जैसा data.
80% CV का मतलब है कि आम दूरी mean का 80% है — values अपने केंद्र के मुक़ाबले बहुत बिखरी हैं।
कम CV = ज़्यादा एक जैसा। ज़्यादा CV = ज़्यादा बदलने वाला।
CV 为 8%,表示与均值的典型距离只有均值的 8% —— 非常稳定。
CV 为 80%,表示典型距离达到均值的 80% —— 相对于中心,数值非常分散。
CV 越低越稳定,越高越多变。
Step-by-Step Calculation — Three InvestmentsStep-by-Step गणना — तीन Investments分步计算 — 三项投资
An investor compares Gold, a Tech Stock and Government Bonds over five years. She wants to know how much the returns swing relative to their average.
एक investor पाँच साल के Gold, एक Tech Stock और Government Bonds की तुलना करती है। वह जानना चाहती है कि returns अपने औसत के मुक़ाबले कितना ऊपर-नीचे होते हैं।
一位投资者比较黄金、一只科技股和政府债券五年的表现。她想知道收益相对于平均水平波动有多大。
| AssetAsset资产 | Annual returns (%)सालाना returns (%)年收益率(%) | Mean x̄Mean x̄均值 x̄ | Std dev sStd dev s标准差 s |
|---|---|---|---|
| GoldGold黄金 | 8, 10, 7, 11, 9 | 9.0% | 1.58% |
| Tech StockTech Stock科技股 | −5, 30, 12, 45, 18 | 20.0% | 18.83% |
| Gov BondsGov Bonds政府债券 | 4, 4, 5, 4, 4 | 4.2% | 0.45% |
Moderate variability — fairly consistent.
मध्यम बदलाव — काफ़ी एक जैसा।
中等波动 —— 相当稳定。
CV = (18.83 / 20.0) × 100 = 94.1% — you might gain 45% or lose 5% in a year.
CV = (18.83 / 20.0) × 100 = 94.1% — एक साल में 45% फ़ायदा या 5% नुक़सान हो सकता है।
CV = (18.83 / 20.0) × 100 = 94.1% —— 一年可能赚 45%,也可能亏 5%。
Low variability — predictable year after year.
कम बदलाव — हर साल अनुमान लगाने लायक।
波动低 —— 年年可预期。
The tech stock has the highest average return (20%), but per unit of return it swings about 9× more than bonds (94.1 / 10.6 ≈ 8.8).
Tech stock का औसत return सबसे ज़्यादा (20%) है, पर return की हर unit पर यह bonds से लगभग 9 गुना ज़्यादा झूलता है (94.1 / 10.6 ≈ 8.8)।
科技股的平均收益最高(20%),但每单位收益的波动约是债券的 9 倍(94.1 / 10.6 ≈ 8.8)。
CV is "risk per unit of return". Its inverse, mean / SD, is "return per unit of risk" — which is the Sharpe ratio when the risk-free rate is set to zero (the real Sharpe ratio subtracts the risk-free rate first). A cautious investor may prefer bonds (CV 10.6%) to the tech stock (CV 94.1%) despite the lower return.
Caution: returns can be negative, so CV of returns is fragile — if an asset's average return is close to zero, its CV explodes (Section 8).
CV "return की हर unit पर risk" है। इसका उल्टा, mean / SD, "risk की हर unit पर return" है — जो risk-free rate को zero मानने पर Sharpe ratio होता है (असली Sharpe ratio पहले risk-free rate घटाता है)। सावधान investor कम return के बावजूद tech stock (CV 94.1%) की जगह bonds (CV 10.6%) चुन सकता है।
सावधानी: returns negative हो सकते हैं, इसलिए returns का CV नाज़ुक है — अगर किसी asset का औसत return zero के पास हो, तो उसका CV फट जाता है (Section 8)।
CV 是“每单位收益承担的风险”。它的倒数 均值 / 标准差 是“每单位风险获得的收益” —— 当无风险利率设为零时就是夏普比率(真正的夏普比率要先减去无风险利率)。谨慎的投资者可能宁愿选债券(CV 10.6%),而不选收益更高的科技股(CV 94.1%)。
注意:收益可能为负,所以收益率的 CV 很脆弱 —— 如果某资产的平均收益接近零,它的 CV 会爆炸(见第 8 节)。
Real-World Stories by Fieldक्षेत्र के हिसाब से असली कहानियाँ各领域的真实故事
🏭 Manufacturing — comparing two machines🏭 Manufacturing — दो machines की तुलना🏭 制造业 —— 比较两台机器
A factory runs two machines. Machine A makes 50 mm bolts with σ = 2 mm (CV = 4%). Machine B makes 8 mm micro-screws with σ = 1 mm (CV = 12.5%). Machine A has the larger absolute deviation, yet it is the more consistent machine relative to what it makes. Machine B needs attention even though its SD looks smaller. CV shows what raw numbers hide.
एक factory में दो machines हैं। Machine A 50 mm के bolts बनाती है, σ = 2 mm (CV = 4%)। Machine B 8 mm के micro-screws बनाती है, σ = 1 mm (CV = 12.5%)। Machine A का absolute deviation बड़ा है, फिर भी अपने बनाए सामान के हिसाब से वह ज़्यादा एक जैसी है। Machine B पर ध्यान देने की ज़रूरत है, भले ही उसका SD छोटा दिखे। CV वह दिखाता है जो कच्ची संख्याएँ छिपाती हैं।
工厂有两台机器。机器 A 生产 50 mm 螺栓,σ = 2 mm(CV = 4%)。机器 B 生产 8 mm 微型螺钉,σ = 1 mm(CV = 12.5%)。机器 A 的绝对偏差更大,但相对于它的产品,它更稳定。机器 B 尽管标准差看起来更小,却需要检修。CV 揭示了原始数字掩盖的东西。
🧪 Laboratory science — test precision🧪 Laboratory science — test की precision🧪 实验室科学 —— 检测精密度
In clinical laboratories, CV is the standard way to report the precision of a test: the same sample is measured many times and the CV of the results is reported. For many routine tests, labs aim for a CV of a few percent (often below 5%); if a new analyser shows 15%, it is recalibrated or replaced. Because CV is relative, the same target can be used at low and high concentrations.
Clinical laboratories में CV किसी test की precision बताने का standard तरीका है: एक ही sample को कई बार मापा जाता है और नतीजों का CV बताया जाता है। बहुत से routine tests के लिए labs कुछ प्रतिशत (अक्सर 5% से कम) का CV चाहती हैं; अगर नया analyser 15% दिखाए, तो उसे recalibrate या बदल दिया जाता है। CV relative है, इसलिए कम और ज़्यादा concentrations पर एक ही target इस्तेमाल हो सकता है।
在临床实验室,CV 是报告检测精密度的标准方法:同一样本重复测量多次,报告结果的 CV。许多常规检测要求 CV 只有几个百分点(通常低于 5%);如果新分析仪显示 15%,就要重新校准或更换。由于 CV 是相对的,高低浓度都可以用同一个目标值。
Climate scientists use the CV of yearly rainfall to judge how dependable rain is. A low CV means the rain arrives in similar amounts most years; a high CV means wet and dry years swing wildly. Dry regions such as parts of the Sahel and north-western India have much higher rainfall CVs than wet regions — not only because the average is low, but because it is unpredictable. That is why farming there depends so much on irrigation and drought planning.
Climate scientists सालाना बारिश के CV से यह आँकते हैं कि बारिश कितनी भरोसेमंद है। कम CV = ज़्यादातर सालों में लगभग उतनी ही बारिश; ऊँचा CV = गीले और सूखे साल बहुत झूलते हैं। Sahel के कुछ हिस्सों और उत्तर-पश्चिम भारत जैसे सूखे इलाक़ों में बारिश का CV गीले इलाक़ों से बहुत ज़्यादा है — सिर्फ़ इसलिए नहीं कि औसत कम है, बल्कि इसलिए कि वह अनिश्चित है। इसीलिए वहाँ खेती irrigation और सूखे की तैयारी पर इतनी निर्भर है।
气候学家用年降雨量的 CV 来判断降雨是否可靠。CV 低,意味着大多数年份雨量相近;CV 高,意味着丰水年和干旱年波动剧烈。萨赫勒部分地区和印度西北部等干旱地区的降雨 CV 远高于湿润地区 —— 不只因为平均值低,更因为它难以预测。所以那里的农业高度依赖灌溉和抗旱规划。
📊 Data science — comparing features before modelling📊 Data science — modelling से पहले features की तुलना📊 数据科学 —— 建模前比较特征
Before training a model, a data scientist compares two features: annual_income (mean ₹600,000, SD ₹420,000, CV = 70%) and age (mean 35 years, SD 9 years, CV = 26%). The SDs cannot be compared (rupees vs years), but the CVs can: income varies almost three times as much relative to its mean. A high CV like this often signals a skewed feature that may benefit from a log transform before modelling.
Model train करने से पहले एक data scientist दो features की तुलना करता है: annual_income (mean ₹600,000, SD ₹420,000, CV = 70%) और age (mean 35 साल, SD 9 साल, CV = 26%)। SDs की तुलना नहीं हो सकती (रुपये vs साल), पर CVs की हो सकती है: income अपने mean के हिसाब से लगभग तीन गुना ज़्यादा बदलती है। ऐसा ऊँचा CV अक्सर skewed feature का संकेत है, जिसे modelling से पहले log transform से फ़ायदा हो सकता है।
训练模型前,数据科学家比较两个特征:annual_income(均值 ₹600,000,标准差 ₹420,000,CV = 70%)和 age(均值 35 岁,标准差 9 岁,CV = 26%)。两个标准差无法比较(卢比 vs 年),但 CV 可以:收入相对于均值的波动几乎是年龄的三倍。这么高的 CV 往往意味着特征是偏斜的,建模前做对数变换可能会有帮助。
Python ImplementationPython ImplementationPython 实现
Manual calculation with NumPyNumPy से हाथ वाली गणना用 NumPy 手动计算
import numpy as np
# Annual returns (%) of three investments
gold = [8, 10, 7, 11, 9]
tech_stock = [-5, 30, 12, 45, 18]
gov_bonds = [4, 4, 5, 4, 4]
def cv(data):
"""Sample coefficient of variation, as a percentage."""
arr = np.array(data)
return np.std(arr, ddof=1) / np.mean(arr) * 100
for name, data in [("Gold", gold), ("Tech Stock", tech_stock), ("Gov Bonds", gov_bonds)]:
print(f"{name:<11} mean = {np.mean(data):5.1f}% s = {np.std(data, ddof=1):6.2f}% CV = {cv(data):6.2f}%")
Using SciPySciPy से使用 SciPy
from scipy.stats import variation
gold = [8, 10, 7, 11, 9]
tech_stock = [-5, 30, 12, 45, 18]
gov_bonds = [4, 4, 5, 4, 4]
# variation() returns a ratio (not %) and uses ddof=0 by default
for name, data in [("Gold", gold), ("Tech Stock", tech_stock), ("Gov Bonds", gov_bonds)]:
print(f"{name:<11} ddof=0: {variation(data) * 100:6.2f}% ddof=1: {variation(data, ddof=1) * 100:6.2f}%")
scipy.stats.variation() returns a ratio, not a percentage, and uses ddof = 0 by default — notice how much lower those values are with only five data points.
scipy.stats.variation() percentage नहीं, ratio देता है, और default में ddof = 0 इस्तेमाल करता है — देखें कि सिर्फ़ पाँच data points पर ये values कितनी कम हैं।
scipy.stats.variation() 返回的是比值而不是百分比,默认 ddof = 0 —— 注意只有五个数据点时这些值低了多少。
Using pandaspandas से使用 pandas
import pandas as pd
df = pd.DataFrame({
'gold': [8, 10, 7, 11, 9],
'tech_stock': [-5, 30, 12, 45, 18],
'gov_bonds': [4, 4, 5, 4, 4],
})
cv_series = df.std() / df.mean() * 100 # pandas .std() uses ddof=1
print("Ranked by consistency (lowest CV first):")
print(cv_series.sort_values().round(2))
CV for many features — an EDA reportकई features का CV — एक EDA report多个特征的 CV —— EDA 报告
import pandas as pd
import numpy as np
rng = np.random.default_rng(42)
n = 500
df = pd.DataFrame({
'age': rng.normal(35, 9, n).clip(18, 80),
'annual_income': rng.lognormal(13, 0.7, n),
'purchase_amt': rng.exponential(2500, n),
'loyalty_score': rng.normal(70, 5, n).clip(0, 100),
})
cv_report = pd.DataFrame({
'mean': df.mean(),
'std': df.std(),
'cv_pct': df.std() / df.mean() * 100,
}).sort_values('cv_pct', ascending=False).round(1)
print(cv_report)
Purchase amount (exponential, CV ≈ 100% in theory) and income (log-normal, CV ≈ 80%) are the most variable; loyalty score is the most consistent. Features with very high CV are usually skewed — check a histogram before modelling.
Purchase amount (exponential, theory में CV ≈ 100%) और income (log-normal, CV ≈ 80%) सबसे ज़्यादा बदलते हैं; loyalty score सबसे एक जैसा है। बहुत ऊँचे CV वाले features आम तौर पर skewed होते हैं — modelling से पहले histogram देखें।
消费金额(指数分布,理论 CV ≈ 100%)和收入(对数正态,CV ≈ 80%)波动最大;忠诚度评分最稳定。CV 很高的特征通常是偏斜的 —— 建模前先看直方图。
np.std() defaults to ddof=0 (population). scipy.stats.variation() also defaults to ddof=0. pandas .std() defaults to ddof=1 (sample). For a sample CV — almost always what you want — pass ddof=1 to NumPy and SciPy.
np.std() का default ddof=0 (population) है। scipy.stats.variation() का default भी ddof=0 है। pandas .std() का default ddof=1 (sample) है। Sample CV के लिए — जो लगभग हमेशा चाहिए — NumPy और SciPy में ddof=1 दें।
np.std() 默认 ddof=0(总体)。scipy.stats.variation() 默认也是 ddof=0。pandas 的 .std() 默认 ddof=1(样本)。要算样本 CV(几乎总是如此),请给 NumPy 和 SciPy 传入 ddof=1。
When CV Breaks — Units, Zero and Negative ValuesCV कब टूटता है — Units, Zero और Negative ValuesCV 何时失效 — 单位、零与负值
CV divides by the mean, so it only means something when the mean measures "how much of it there is". Two quick tests show when that is true.
CV mean से भाग देता है, इसलिए इसका मतलब तभी है जब mean यह मापे कि "कितना है"। दो छोटे tests दिखाते हैं कि यह कब सच है।
CV 要除以均值,所以只有当均值衡量的是“有多少”时才有意义。两个小测试能说明何时成立。
Test 1 — change the unitTest 1 — unit बदलें测试 1 —— 换单位
import numpy as np
def cv(x):
return np.std(x, ddof=1) / np.mean(x) * 100
heights_cm = np.array([152, 160, 165, 170, 178, 185])
print(f"Heights cm: SD = {np.std(heights_cm, ddof=1):6.2f} CV = {cv(heights_cm):.2f}%")
print(f"Heights in: SD = {np.std(heights_cm / 2.54, ddof=1):6.2f} CV = {cv(heights_cm / 2.54):.2f}%")
temps_c = np.array([12, 15, 18, 21, 24, 27])
temps_f = temps_c * 9 / 5 + 32
temps_k = temps_c + 273.15
print(f"\nTemps °C: CV = {cv(temps_c):6.2f}%")
print(f"Temps °F: CV = {cv(temps_f):6.2f}%")
print(f"Temps K: CV = {cv(temps_k):6.2f}% <- same days, three different 'answers'")
Heights have a true zero; temperatures in °C and °F do not. Switch units and watch which CV stays put.
Heights का true zero होता है; °C और °F में तापमान का नहीं। Units बदलें और देखें कौन सा CV वहीं रहता है।
身高有真正的零点;摄氏和华氏温度没有。切换单位,看哪个 CV 保持不变。
Test 2 — move the mean towards zeroTest 2 — mean को zero की ओर ले जाएँ测试 2 —— 让均值靠近零
import numpy as np
def cv(x):
return np.std(x, ddof=1) / np.mean(x) * 100
steady = np.array([9, 11, 8, 12, 10]) # returns (%), mean 10
flat = steady - 9.8 # SAME spread, mean 0.2
losing = steady - 20 # SAME spread, mean -10
for name, r in [("mean 10%", steady), ("mean 0.2%", flat), ("mean -10%", losing)]:
print(f"{name:<10} SD = {np.std(r, ddof=1):.2f} CV = {cv(r):9.1f}%")
All three return series have exactly the same spread (SD 1.58). Only the mean differs — and CV goes from 15.8% to 790.6% to a meaningless −15.8%.
तीनों return series का फैलाव बिल्कुल एक (SD 1.58) है। सिर्फ़ mean अलग है — और CV 15.8% से 790.6% और फिर बेमतलब −15.8% हो जाता है।
三组收益序列的离散程度完全相同(标准差 1.58),只有均值不同 —— CV 却从 15.8% 变成 790.6%,再变成毫无意义的 −15.8%。
Five values with a fixed spread. Shift them all left or right. The lower chart shows CV for every possible mean.
तय फैलाव वाली पाँच values. सबको बाएँ या दाएँ खिसकाएँ। नीचे का chart हर संभव mean के लिए CV दिखाता है।
五个离散程度固定的值。把它们整体左移或右移。下方图表显示每种可能均值下的 CV。
CV vs Standard Deviation — When to Use WhichCV vs Standard Deviation — कब कौन साCV vs 标准差 — 何时用哪个
| Propertyगुण特性 | Standard deviationStandard deviation标准差 | Coefficient of variationCoefficient of variation变异系数 |
|---|---|---|
| UnitUnit单位 | Same as the dataData जैसी ही与数据相同 | None (a %)कोई नहीं (%)无(百分比) |
| Compare datasets with the same unit and similar meansएक unit और मिलते-जुलते means वाले datasets की तुलना比较单位相同、均值相近的数据集 | Yesहाँ可以 | Yesहाँ可以 |
| Compare datasets with very different meansबहुत अलग means वाले datasets की तुलना比较均值差异很大的数据集 | Misleadingगुमराह करने वाला会误导 | Yesहाँ可以 |
| Compare across different unitsअलग units के बीच तुलना跨单位比较 | Not possibleसंभव नहीं不可能 | Yesहाँ可以 |
| Mean near zero or negative valuesMean zero के पास या negative values均值接近零或有负值 | Worksचलता है可用 | Breaksटूट जाता है失效 |
| Interval data (°C, °F)Interval data (°C, °F)定距数据(°C、°F) | Worksचलता है可用 | Meaninglessबेमतलब无意义 |
| Lab precision / QC reportsLab precision / QC reports实验室精密度 / 质控报告 | Sometimesकभी-कभी有时 | StandardStandard标准做法 |
Spread within one dataset, or across datasets with the same unit and similar means? Use the standard deviation.
Spread across different units, or across very different scales? Use CV — if the data is positive and has a true zero.
Mean near zero, negative values, or interval data? Do not use CV; report the SD (or IQR / MAD for skewed data).
एक dataset के अंदर, या एक unit और मिलते-जुलते means वाले datasets के बीच फैलाव? Standard deviation लें।
अलग units, या बहुत अलग scales के बीच फैलाव? CV लें — अगर data positive हो और उसका true zero हो।
Mean zero के पास, negative values, या interval data? CV न लें; SD बताएँ (या skewed data के लिए IQR / MAD)।
单个数据集内部,或单位相同、均值相近的数据集之间的离散程度?用标准差。
不同单位之间,或尺度差异很大时的离散程度?用 CV —— 前提是数据为正且有真正的零点。
均值接近零、存在负值,或是定距数据?不要用 CV;报告标准差(偏斜数据可用 IQR / MAD)。
Golden RulesGolden Rules黄金法则
np.std() and scipy.stats.variation() default to ddof=0; pandas .std() defaults to ddof=1. With small samples the difference is large (15.7% vs 17.6% for gold).np.std() और scipy.stats.variation() का default ddof=0 है; pandas .std() का ddof=1. छोटे samples में अंतर बड़ा होता है (gold के लिए 15.7% vs 17.6%)।np.std() 和 scipy.stats.variation() 默认 ddof=0;pandas 的 .std() 默认 ddof=1。小样本时差别很大(黄金:15.7% vs 17.6%)。