Statistics for Data Science · Day 5

Relative Measures of Dispersion

Context is everything: comparing spread with CV and CQD.

By Shikhar · Series continued · ~12 min read

In Day 4, we covered absolute measures of spread: range, variance, standard deviation, MAD, and IQR. These are all useful tools, but they share one blind spot. They give you a number, and that number has no context. Today we fix that.

The problem with absolute measures

Absolute measures of dispersion give you a single number for spread. Bigger number means more spread, smaller number means the data is packed tightly together. Simple enough, until you try to compare two very different datasets.

Here's the problem: is a standard deviation of 200 big or small?

The honest answer is: it depends entirely on the mean.

If the mean is 150... this whole bar is "the mean" SD (200) overshoots the mean itself If the mean is 2,000,000... this whole bar is "the mean" SD (200) is that thin line, 0.01% of the mean
Same spread, the number 200, told two completely different stories depending on what it's being compared to.

The number 200 means something completely different in each case. That's the core problem with absolute measures: on their own, they never tell you what "big" or "small" actually means.

Relative measures of dispersion fix this. Instead of giving you a raw number, they compare the spread to the centre of the data. The result is a ratio with no units attached, so it stays meaningful no matter what scale or units the original data used. That's what lets you fairly compare things like how consistent salaries are across two companies, or how stable satisfaction scores are across two products.

In this article we'll cover two key relative measures:

Absolute vs. relative measures at a glance

Absolute measuresRelative measures
OutputA value in the original units (like $, cm, points)A unitless ratio or percentage
Useful forDescribing spread within a single datasetComparing spread across different datasets
ExamplesRange, variance, SD, MAD, IQRCV, CQD
LimitationCan't be fairly compared across different scalesNeeds a central value that actually makes sense to divide by

Coefficient of Variation (CV)

The Coefficient of Variation turns the standard deviation into a percentage of the mean. It answers one question: how big is the spread, compared to the average?

CV = Standard DeviationMean × 100%

A higher CV means more variability relative to the mean. A lower CV means the data is more consistent relative to its own average.

Key insight

CV has no units. Whether you're comparing salaries in dollars, heights in centimetres, or temperatures in Celsius, CV gives you a fair, apples-to-apples comparison.

Worked example: salary consistency across companies

A recruiter wants to know which company actually offers more consistent salaries.

pythonimport numpy as np def coefficient_of_variation(data): mean = np.mean(data) std = np.std(data, ddof=1) return (std / mean) * 100 company_a = [45000, 48000, 50000, 52000, 55000] company_b = [150000, 155000, 160000, 165000, 170000] mean_a, std_a = np.mean(company_a), np.std(company_a, ddof=1) mean_b, std_b = np.mean(company_b), np.std(company_b, ddof=1) print(f"Company A: mean=${mean_a:,.2f} SD=${std_a:,.2f} CV={coefficient_of_variation(company_a):.2f}%") print(f"Company B: mean=${mean_b:,.2f} SD=${std_b:,.2f} CV={coefficient_of_variation(company_b):.2f}%")
OutputCompany A: mean=$50,000.00 SD=$3,807.89 CV=7.62% Company B: mean=$160,000.00 SD=$7,905.69 CV=4.94%
Company ACompany B
Mean salary$50,000.00$160,000.00
Standard deviation$3,807.89$7,905.69
CV7.62%4.94%

If you only looked at the standard deviation, you'd say Company B's salaries are more variable, since its SD ($7,905.69) is roughly double Company A's ($3,807.89). That conclusion is misleading.

The CV tells the real story: Company B's salaries are actually more consistent relative to their own scale. A spread of about $7,900 around a $160,000 mean matters a lot less than a spread of about $3,800 around a $50,000 mean.

7.62% Company A 4.94% Company B
Coefficient of variation for both companies. Company B's bar is shorter: less spread relative to its own average, even though its dollar-value SD is bigger.

More real-world uses of CV

DomainHow CV is used
FinanceComparing the risk-to-return ratio across investments with different average returns
ManufacturingMonitoring production consistency, where a low CV means high quality control
MedicineComparing how variable lab measurements are across tests that use completely different scales
Machine learningChecking how stable a model's performance is across different cross-validation folds

When not to use CV

CV has two real limitations worth knowing.

First, never use CV when the mean is zero or close to it. Dividing by zero, or by a number close to zero, gives you either an undefined result or a meaninglessly huge one.

Second, be careful with CV on data that can go negative, like profit and loss figures, or temperatures in Celsius. A negative mean makes the sign of the CV confusing and hard to read. In cases like these, stick with an absolute measure instead.

Note

In finance, a closely related idea is the Sharpe Ratio, which measures investment return compared to risk. It's basically a version of CV, built specifically for investment performance.

Coefficient of Quartile Deviation (CQD)

The Coefficient of Quartile Deviation is the relative version of the IQR. The same way CV compares the SD to the mean, CQD compares the IQR to the sum of Q1 and Q3.

CQD = Q3 − Q1Q3 + Q1

The result always lands somewhere between 0 and 1 (or 0% to 100% if you multiply by 100). Closer to 0 means the middle 50% of the data is packed tightly together. Closer to 1 means it's spread wide.

Why CQD over CV?

Because CQD is built from quartiles instead of the mean and standard deviation, it comes with three useful properties:

That makes CQD the right tool whenever your data has outliers, is skewed, or when you specifically want to measure the consistency of your "typical" users while ignoring the extreme cases.

Worked example: product satisfaction comparison

A market research analyst wants to compare how consistent satisfaction is across two software products. Product A has a few extremely low scores from users who happened to hit a rare bug, and the analyst wants to understand the core user experience without those outliers throwing off the result.

Customer satisfaction scores (on a 1 to 100 scale) from 11 users of each product:

Product A (sorted): 25, 78, 80, 81, 84, 85, 88, 90, 91, 95, 98
Product B (sorted): 65, 68, 70, 72, 75, 79, 85, 88, 92, 96, 99

Finding quartiles for 11 values

For a sorted dataset of exactly 11 values, there's a simple shortcut:

Product AProduct B
Q1 (3rd value)8070
Q3 (9th value)9192
IQR (Q3 − Q1)1122
Q3 + Q1171162
CQD11/171 ≈ 0.06422/162 ≈ 0.136
0 20 40 60 80 100 Product A Q1 to Q3 one user hit a bug: score 25 CQD (manual) = 0.064 Product B Q1 to Q3 CQD (manual) = 0.136
Both products on the same 1–100 scale. Product A's Q1–Q3 box (blue) is much narrower than Product B's (teal), and the score-25 outlier sits nowhere near it.

Interpretation: Product A's CQD (0.064) is less than half of Product B's (0.136). The middle 50% of Product A's users gave far more consistent scores. And here's the important part: that outlier score of 25 for Product A had zero say in this result, since it falls completely outside the Q1 to Q3 range.

If the analyst had used standard deviation instead, Product A's outlier would have dragged its SD way up, possibly making Product A look less consistent than Product B. That would have been the wrong conclusion, driven entirely by one unlucky user's bug report.

pythonproduct_a = [25, 78, 80, 81, 84, 85, 88, 90, 91, 95, 98] product_b = [65, 68, 70, 72, 75, 79, 85, 88, 92, 96, 99] def coeff_quartile_deviation(data): q1 = np.percentile(data, 25) q3 = np.percentile(data, 75) return (q3 - q1) / (q3 + q1) print(f"Product A CQD: {coeff_quartile_deviation(product_a):.3f}") print(f"Product B CQD: {coeff_quartile_deviation(product_b):.3f}")
OutputProduct A CQD: 0.058 Product B CQD: 0.118
The code gives different numbers, and that's expected

Run the code above and you'll get 0.058 for Product A and 0.118 for Product B, not the 0.064 and 0.136 from the hand-calculated table. This is the exact same gap we ran into with IQR back in Day 1 and Day 4. NumPy's percentile function uses linear interpolation by default, while the "3rd value, 9th value" shortcut above is the plain textbook method. Neither is wrong, they're just different rulers. The good news is the conclusion survives either way: Product A's CQD is still well under half of Product B's, so the story you'd tell a stakeholder doesn't change. But if you're ever matching a manual calculation against code output number for number, check which method the code is actually using first.

CV vs. CQD: which one to use?

SituationUse
Data is clean, symmetric, no major outliersCV
Data has outliers or is skewedCQD
Comparing investment risk vs. returnCV
Comparing consistency of customer satisfaction scoresCQD
Mean is zero or negativeNeither. Use IQR or MAD instead
You need one consistency benchmark across many different datasetsCV (the most widely used in practice)

Putting it all together: the full dispersion toolkit

Now that we've covered both absolute and relative measures, here's the complete picture.

MeasureTypeOutlier sensitive?Best for
RangeAbsoluteVeryA quick first look
VarianceAbsoluteYesFeeding into other calculations
Standard deviationAbsoluteYesClean, symmetric data
MADAbsoluteRobustSkewed data, anomaly detection
IQRAbsoluteRobustSkewed data, box plots
CVRelativeYesComparing datasets with different means
CQDRelativeRobustComparing datasets that have outliers

Key takeaway and a practical tip

Whenever you want to compare the spread of two or more datasets that have different means or different units, don't compare absolute measures directly. Switch to a relative measure first.

A quick decision rule:

Quick check

Three questions to test whether this stuck.

Two machines both have a standard deviation of 0.5mm in the parts they produce. Machine A makes parts averaging 10mm. Machine B makes parts averaging 200mm. Which machine is actually less consistent?

Machine A. Its CV is 0.5/10 × 100% = 5%, while Machine B's is 0.5/200 × 100% = 0.25%. The same absolute SD is a much bigger deal relative to Machine A's smaller average part size.

Why can't you calculate a sensible CV for a dataset of daily temperature changes in Celsius, some positive, some negative?

Because the mean could land at or near zero, or even be negative. Dividing the standard deviation by a number near zero blows up the CV into a huge, meaningless value, and a negative mean makes the sign of the result confusing. This is exactly the kind of data CQD or an absolute measure handles better.

A dataset has a couple of extreme outliers. Would you reach for CV or CQD to describe its spread, and why?

CQD. It's built from quartiles, so those outliers land outside the Q1 to Q3 window and have zero effect on the result. CV is built from the mean and standard deviation, both of which outliers can drag around a lot.

Up next in the series

Correlation and Covariance: why a data scientist should care whether two variables move together, and how to measure it.