Relative Measures of Dispersion

Is a spread of 200 big or small? It depends on what it's spread around. The coefficient of variation and the coefficient of quartile deviation answer that question, and today you'll also learn when they quietly mislead.

Two machines, both with a standard deviation of 0.5 mm

10 mm screwsCV 5%0.5 mm is a big wobble on a small part
200 mm rodsCV 0.25%the same 0.5 mm barely registers
Identical standard deviations, very different levels of consistency. Dividing the spread by the average is what reveals the difference.

On Day 4 we measured spread with range, variance, standard deviation, MAD and the IQR. They all share one blind spot: they report spread in the data's own units, with no sense of scale. Today we fix that by measuring spread relative to the centre.

Is a standard deviation of 200 big or small?

Think about running late. Being 5 minutes late for a 10-minute video call means you missed half of it. Being 5 minutes late for a 10-hour flight's arrival is something nobody notices. The delay is the same; what changes is the size of the thing it's measured against.

Spread works the same way. An SD of 200 means something completely different depending on the mean:

That's the core problem with absolute measures: on their own, they never tell you what "big" or "small" means. It gets even harder when two datasets are in different units altogether. Is an SD of 5 cm in people's heights more or less than an SD of 8 kg in their weights? There's no way to compare centimetres with kilograms directly.

A real dataset: the iris flowers

The iris dataset is one of the oldest datasets in statistics. It holds measurements of 150 iris flowers, collected by the botanist Edgar Anderson and made famous by the statistician Ronald Fisher in 1936. It ships with scikit-learn, so you can run this yourself:

Pythonimport numpy as np import pandas as pd from sklearn.datasets import load_iris iris = load_iris(as_frame=True).frame cols = ["sepal length (cm)", "petal width (cm)"] summary = pd.DataFrame({ "mean": iris[cols].mean(), "SD": iris[cols].std(), }) summary["SD as % of mean"] = summary["SD"] / summary["mean"] * 100 print(summary.round(2))
Output mean SD SD as % of mean sepal length (cm) 5.84 0.83 14.17 petal width (cm) 1.20 0.76 63.56

Look at the SDs alone and the two measurements seem about equally variable: 0.83 cm against 0.76 cm. But sepal length averages 5.84 cm while petal width averages only 1.20 cm. Relative to its own size, petal width varies more than four times as much (64% against 14%). That last column is today's first tool.

Relative measures of dispersion divide a measure of spread by a measure of centre. The units cancel out, leaving a pure ratio (often shown as a percentage), so you can compare datasets on different scales, or even in different units. We'll cover the two common ones:

Absolute vs. relative at a glance

Absolute measuresRelative measures
OutputA value in the data's units ($, cm, ms)A unitless ratio or percentage
Good forDescribing spread within one datasetComparing spread across datasets with different scales or units
ExamplesRange, variance, SD, MAD, IQRCV, CQD
Main limitationCan't be fairly compared across different scalesOnly valid for positive, ratio-scale data (more on this below)

Coefficient of variation (CV)

The coefficient of variation expresses the standard deviation as 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. Because the SD and the mean are in the same units, those units cancel, which is what lets you compare a CV for heights in centimetres with a CV for weights in kilograms. (Some fields also call it the relative standard deviation, or RSD.)

Worked example: which company pays more consistently?

A recruiter wants to know which of two companies offers more consistent salaries.

Pythondef coefficient_of_variation(data): return np.std(data, ddof=1) / np.mean(data) * 100 company_a = [45000, 48000, 50000, 52000, 55000] company_b = [150000, 155000, 160000, 165000, 170000] for name, x in [("Company A", company_a), ("Company B", company_b)]: print(f"{name}: mean=${np.mean(x):,.0f} SD=${np.std(x, ddof=1):,.2f} CV={coefficient_of_variation(x):.2f}%")
OutputCompany A: mean=$50,000 SD=$3,807.89 CV=7.62% Company B: mean=$160,000 SD=$7,905.69 CV=4.94%
Standard deviation in dollars Company A $3,808 Company B $7,906 B looks more variable Coefficient of variation SD as a % of the mean Company A 7.62% Company B 4.94% A is the less consistent one Standard deviation in dollars Company A $3,808 Company B $7,906 B looks more variable Coefficient of variation SD as a % of the mean Company A 7.62% Company B 4.94% A is the less consistent one
The two measures rank the companies in opposite orders. Company B's salaries spread over more dollars, but each of those dollars matters less against a $160,000 average.

Judge by the SD alone and Company B looks more variable: its SD of $7,906 is about double Company A's $3,808. But a $7,900 spread around a $160,000 average is a smaller deal than a $3,800 spread around a $50,000 one. The CV makes that explicit: 4.94% for B against 7.62% for A. Relative to what people there typically earn, Company A's salaries are the less consistent ones.

What counts as a "high" CV?

There's no universal cut-off. A CV of 10% might be excellent for monthly sales and alarming for a laboratory scale. Fields set their own standards, and the most useful comparisons are between similar things: two machines making the same part, two branches of the same shop, the same metric this month and last month.

Real case: how drug labs judge their measurements

CV as a pass/fail rule

When a pharmaceutical lab develops a test to measure a drug's concentration in blood samples, regulators want proof that the test is precise. The US Food and Drug Administration's acceptance limits for this kind of test are written as CVs: repeated measurements of the same sample should have a CV of no more than 15%, loosened to 20% at the lowest concentration the test claims to measure.

Why a CV and not an SD? The same test runs at very different concentrations, and its SD in absolute units tends to grow as the concentration grows. An SD rule would be too strict at high levels and too loose at low ones. A CV rule asks the same question everywhere: how big is the wobble compared to what you're measuring?

More places you'll meet the CV

DomainHow the CV is used
ManufacturingComparing how consistently different production lines or machines hit their targets, even when they make parts of different sizes.
Laboratory scienceReporting the precision of a measurement method across different concentrations, as in the case above.
Business metricsComparing how stable sales, demand or traffic are across stores or products of very different sizes.
FinanceComparing how volatile investments are relative to their average return (see the Sharpe ratio note below).
Machine learningChecking how stable a model's score is across cross-validation folds (watch out for the name clash below).
Name clash: "CV" in machine learning

In machine learning, "CV" almost always means cross-validation, as in scikit-learn's cv=5 argument, not the coefficient of variation. You can even compute the coefficient of variation of your cross-validation scores. When you write about either one, spell it out the first time.

A cousin in finance: the Sharpe ratio

In 1966 the economist William Sharpe proposed a "reward-to-variability ratio" for judging mutual funds in the Journal of Business. Today it's called the Sharpe ratio: an investment's average return above a safe benchmark, divided by the standard deviation of that extra return. It's essentially the CV turned upside down, with return on top. So the direction flips too: for a CV, lower means more consistent; for a Sharpe ratio, higher means more reward for each unit of risk.

When the CV misleads

Dividing by the mean is what makes the CV useful, and it's also where it breaks. Three situations to watch for.

1. The mean is zero or close to it

Dividing by zero is undefined, and dividing by a tiny number gives a huge, meaningless result. Daily profit-and-loss figures, temperature changes and stock price changes all hover around zero, so their CV is useless.

2. The data can be negative, or has no true zero

This one is easy to miss, and it connects straight back to Day 2. The CV only makes sense for ratio-scale data, where zero means "none of it" (lengths, weights, money, durations). For interval-scale data such as temperature in Celsius, zero is an arbitrary point, so dividing by the mean gives an arbitrary answer. Here's the proof: three temperatures, written in three different units:

Pythontemps_c = np.array([10, 20, 30]) # degrees Celsius temps_f = temps_c * 9 / 5 + 32 # the same temperatures in Fahrenheit temps_k = temps_c + 273.15 # and in kelvin for unit, t in [("Celsius", temps_c), ("Fahrenheit", temps_f), ("Kelvin", temps_k)]: print(f"{unit:10} CV = {coefficient_of_variation(t):.1f}%")
OutputCelsius CV = 50.0% Fahrenheit CV = 26.5% Kelvin CV = 3.4%

The same three days give a CV of 50%, 26.5% or 3.4%, depending only on which thermometer you read. A measure that changes when you merely relabel the scale isn't measuring anything real. Only kelvin has a true zero (absolute zero), so only the kelvin CV is meaningful. The same caution applies to rating scales such as 1-to-5 stars, which are ordinal (Day 2) and have no true zero either.

3. The data has outliers

The CV is built from the mean and the SD, and Day 4 showed how easily one extreme value drags both. So the CV inherits that weakness, and one bad value can make a perfectly steady process look chaotic. That's the problem our second measure solves.

Coefficient of quartile deviation (CQD)

The coefficient of quartile deviation is the robust version of the CV. Instead of the mean and SD, it uses the first and third quartiles from Day 4:

CQD = Q3 − Q1Q3 + Q1
The name comes from the quartile deviation, half the IQR: (Q3 − Q1) / 2. Dividing it by the midpoint of the two quartiles, (Q3 + Q1) / 2, the halves cancel and you get the formula above.

The top of the fraction is the IQR, the width of the middle half of the data. The bottom plays the role the mean plays in the CV: it tells you the size of a typical value. For data that can't go below zero, the CQD always lands between 0 and 1. Close to 0 means the middle half is packed tightly; closer to 1 means it's spread wide relative to its size.

Why use the CQD instead of the CV?

One thing it does not fix: like the CV, it divides by a centre, so it needs positive, ratio-scale data. Temperatures in Celsius and star ratings are still off limits.

Worked example: two services, one timeout

An engineering team wants to know which of two web services gives users the more consistent experience. They record 11 response times, in milliseconds, for each:

Service A (search API): 82, 85, 88, 90, 91, 93, 95, 97, 99, 104, 2400
Service B (report builder): 420, 450, 480, 510, 540, 560, 600, 630, 660, 700, 760

The two services work on very different scales (around 100 ms against around 600 ms), so absolute spreads aren't comparable. That calls for a relative measure. But Service A also had one request that timed out at 2,400 ms. Watch what that does.

The quartiles by hand

For exactly 11 sorted values, the hand method from Day 4 (the median of each half, leaving out the overall median) has a shortcut: the lower half is the first 5 values, so Q1 is the 3rd value; the upper half is the last 5, so Q3 is the 9th value.

Service AService B
Q1 (3rd value)88480
Q3 (9th value)99660
IQR (Q3 − Q1)11180
Q3 + Q11871,140
CQD11 / 187 ≈ 0.059180 / 1,140 ≈ 0.158
Service A: search API CV 230% · CQD 0.059 a 2,400 ms timeout 80 90 100 2,400 Q1 88 to Q3 99 Service B: report builder CV 19% · CQD 0.158 Q1 480 to Q3 660 400 500 600 700 800 response time in milliseconds (each row has its own scale) Service A: search API CV 230% · CQD 0.059 a 2,400 ms timeout 80 90 100 2,400 Q1 88 to Q3 99 Service B: report builder CV 19% · CQD 0.158 Q1 480 to Q3 660 400 500 600 700 800 response time in milliseconds (each row has its own scale)
Each row has its own scale, with the shaded box marking the middle half (Q1 to Q3, hand method). Service A's axis is broken so the timeout fits. The CV calls Service A wildly inconsistent; the CQD says its typical requests are the steadier of the two.

By the CQD, Service A's middle half (0.059) is far more consistent than Service B's (0.158). Now compare with the CV:

Pythondef cqd(data): q1, q3 = np.percentile(data, [25, 75]) return (q3 - q1) / (q3 + q1) service_a = [82, 85, 88, 90, 91, 93, 95, 97, 99, 104, 2400] service_b = [420, 450, 480, 510, 540, 560, 600, 630, 660, 700, 760] a_without_timeout = service_a[:-1] for name, x in [("A", service_a), ("A, timeout removed", a_without_timeout), ("B", service_b)]: print(f"{name:19} CV = {coefficient_of_variation(x):6.1f}% CQD = {cqd(x):.3f}")
OutputA CV = 230.3% CQD = 0.048 A, timeout removed CV = 7.2% CQD = 0.043 B CV = 18.7% CQD = 0.132

One timeout pushes Service A's CV to 230%, making it look more than ten times as erratic as Service B. Remove that single request and its CV collapses to 7.2%. The CQD barely notices either way: 0.048 with the timeout and 0.043 without.

The code's CQDs (0.048 and 0.132) are a little lower than the hand-calculated ones (0.059 and 0.158). That's the quartile-method difference from Day 4 again: NumPy interpolates between neighbouring values, while the hand method picks the 3rd and 9th values. The conclusion is the same either way, which is what matters. Just don't expect a hand calculation and a library to agree to the third decimal place unless they use the same method.

Robust isn't always what you want

The CQD tells you how consistent a typical request is, and it does that job well. But the user who waited 2.4 seconds for a search result probably cares a lot about that timeout. Performance teams often track high percentiles, such as the slowest 1% of requests, precisely because the rare bad cases matter. Use the CQD to describe the typical experience, and look at the outliers separately rather than pretending they don't exist.

CV or CQD: which one?

SituationUse
Positive, ratio-scale data, roughly symmetric, no major outliersCV
Positive, ratio-scale data with outliers or strong skewCQD
Comparing an investment's return with its volatilityThe Sharpe ratio, CV's cousin
A widely recognised benchmark that others will understandCV (by far the more common of the two)
Mean near zero, negative values, interval scales (Celsius) or ratingsNeither. Compare absolute measures such as the IQR or MAD, on the same scale

The full dispersion toolkit

With Days 4 and 5 together, here's the whole picture:

MeasureTypeRobust to outliers?Best for
RangeAbsoluteNoA quick first look
VarianceAbsoluteNoMaths and models behind the scenes
Standard deviationAbsoluteNoClean, roughly symmetric data
MADAbsoluteYesMessy data, outlier detection
IQRAbsoluteYesSkewed data, box plots
CVRelativeNoComparing clean datasets with different scales or units
CQDRelativeYesComparing datasets with outliers or skew

Key takeaway

When you compare the spread of two or more datasets with different averages or different units, don't compare absolute measures directly. Divide by the centre first. Just check that dividing makes sense.

Quick check

Five questions to test whether this stuck. The answers are one click away.

Two machines both have an SD of 0.5 mm. Machine A makes parts averaging 10 mm; Machine B makes parts averaging 200 mm. Which is 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 wobble is a much bigger deal on a small part.

Why can't you compute a sensible CV for daily temperature changes, some positive and some negative?

Because their mean sits near zero, or may even be negative. Dividing by a number near zero blows the CV up into a huge, meaningless value, and a negative mean makes its sign confusing. Use an absolute measure instead.

A city's daily highs have a CV of 20% when measured in Celsius. A colleague converts them to Fahrenheit and gets a different CV. Which one is right?

Neither. Celsius and Fahrenheit are interval scales whose zero points are arbitrary, so the CV changes whenever you change the scale. Only kelvin, with its true zero, gives a meaningful CV, and in practice an absolute measure like the SD is the better way to describe temperature spread.

A dataset has a couple of extreme outliers. CV or CQD, and why?

The CQD. It's built from Q1 and Q3, which ignore how extreme the outliers are. The CV uses the mean and SD, which outliers drag around, as the 230% CV from a single timeout showed.

Your notebook reports "CV = 0.91" next to a scikit-learn model. Is that a coefficient of variation?

Probably not. In machine learning, "CV" usually means cross-validation, and 0.91 is more likely an average cross-validation score, such as accuracy. Check the code, and spell out which "CV" you mean when you write it up.

Next up, Day 6 Correlation and Covariance

So far we've described one variable at a time. Next: how to tell whether two variables move together, and how strongly.