Search

Search papers and lessons

Coefficient of Variation

Level 2 · 8 min read

The coefficient of variation divides the standard deviation by the mean, giving a unit-free measure of spread that lets you compare variability across different scales.

On this page

  • Colour = topic mix
  • Probability
  • Discrete math
  • Sign in to see your progress

TL;DR

The coefficient of variation, or CV, is the standard deviation divided by the mean. It answers the question "how big is the spread compared with the typical size of the values?" Because the units cancel, the result is a plain number, often shown as a percentage.

That makes it useful for comparing variability between things measured in different units or at different scales, where the raw standard deviation would mislead you.

Where you'll see it: in quality control and lab reports to compare instrument precision, in finance to compare the volatility of assets with different prices, and in machine learning to check whether the work is spread evenly across parts of a system, such as the experts in a mixture-of-experts layer.

Intuition

Spread relative to size

A standard deviation of 5 means very different things depending on what is being measured. If a bridge deflects by 5 millimetres on average, that is small. If a sprinter's times vary by 5 seconds, that is huge. The number 5 alone does not tell you how much the values wobble. You also need to know how big the values are in the first place.

The CV fixes this by dividing by the typical size, the mean. A spread of 5 around a mean of 10 is a large relative wobble, a CV of one half. The same spread of 5 around a mean of 500 is tiny, a CV of one per cent. The arithmetic is simple, but the question it answers is the one people usually care about: is this variable steady or jumpy, given what it normally is?

Mean and variance give you the centre and the spread. The CV combines them into a single relative figure. It is not a different kind of measurement. It is the same spread, rescaled so that the result does not depend on the units.

flowchart LR
    D[data values] --> M[mean: typical size]
    D --> S[standard deviation: spread]
    M --> R[divide spread by size]
    S --> R
    R --> CV[coefficient of variation: unit-free spread]

The math

Definition

For a random variable XX with mean μ\mu and standard deviation σ\sigma, the coefficient of variation is

CV=σμ,μ≠0.\text{CV} = \frac{\sigma}{\mu}, \qquad \mu \ne 0.

Here μ\mu is the mean, the average value of XX, and σ\sigma is the standard deviation, the square root of the variance. The ratio has no units, because the units of σ\sigma and μ\mu are the same and cancel.

For a sample of nn values x1,…,xnx_1, \dots, x_n with sample mean xˉ\bar{x}, the usual estimate is

CV^=sxˉ,s=1n−1∑i=1n(xi−xˉ)2.\widehat{\text{CV}} = \frac{s}{\bar{x}}, \qquad s = \sqrt{\frac{1}{n-1}\sum_{i=1}^{n}(x_i - \bar{x})^2}.

Here ss is the sample standard deviation. The divisor n−1n - 1 is the usual correction for estimating the spread from a sample. Some texts use nn instead, and the choice matters only for small samples.

Two properties

The first property is scale invariance. If every value is multiplied by a constant k>0k > 0, the mean becomes kμk\mu and the standard deviation becomes kσk\sigma. The CV is unchanged:

kσkμ=σμ.\frac{k\sigma}{k\mu} = \frac{\sigma}{\mu}.

Changing units, for example from metres to feet, leaves the CV alone. Changing the currency does too.

The second property is that the CV is defined only when the mean is not zero, and it is meaningful only when the variable is positive. If the mean is near zero, a small change in the mean makes the CV swing wildly. For a variable that takes both signs, the CV can be misleading and another measure is usually better.

Gaussian case

If X∼N(μ,σ2)X \sim \mathcal{N}(\mu, \sigma^2) with μ>0\mu > 0, the CV is σ/μ\sigma/\mu. The bell curve has a fixed shape, so the CV alone tells you how wide that bell is relative to its centre. A CV of 0.10.1 gives a narrow curve with almost all values within 30 per cent of the mean, since ±3σ\pm 3\sigma covers ±0.3μ\pm 0.3\mu. A CV of 11 gives a curve so wide that a large share of values would be negative, which is a warning that a Gaussian is a poor model for a positive quantity at that spread.

00.511.5200.511.52value divided by the meandensity
  • CV = 0.2
  • CV = 0.5
Dividing a Gaussian by its mean gives a Gaussian centred at 1 whose spread is the CV. The two curves differ only in that spread.

Worked examples

Example
Comparing two instruments

Two thermometers measure the same kind of quantity, but on different scales.

  1. Instrument A reads a mean of 100100 with standard deviation 55.
  2. Its CV is 5/100=0.055 / 100 = 0.05, or 5 per cent.
  3. Instrument B reads a mean of 22 with standard deviation 0.30.3.
  4. Its CV is 0.3/2=0.150.3 / 2 = 0.15, or 15 per cent.
  5. Interpretation: B has the smaller absolute spread, 0.30.3 against 55, but the larger relative spread. Judged by the size of its readings, B is the noisier instrument. Comparing raw standard deviations would have ranked them the other way.
Example
Scale does not matter

Take five prices in dollars: 10,12,8,14,610, 12, 8, 14, 6.

  1. The mean is (10+12+8+14+6)/5=50/5=10(10 + 12 + 8 + 14 + 6)/5 = 50/5 = 10.
  2. The deviations from the mean are 0,2,−2,4,−40, 2, -2, 4, -4. Their squares are 0,4,4,16,160, 4, 4, 16, 16, summing to 4040.
  3. The sample variance is 40/4=1040/4 = 10, so s=10=3.162s = \sqrt{10} = 3.162.
  4. The CV is 3.162/10=0.3163.162 / 10 = 0.316, or about 32 per cent.
  5. Now express the same prices in cents: 1000,1200,800,1400,6001000, 1200, 800, 1400, 600. The mean is 10001000 and the standard deviation is 316.2316.2. The CV is 316.2/1000=0.316316.2 / 1000 = 0.316. The number is the same, because multiplying by 100 cancels out.
Example
Load across experts

A mixture-of-experts layer sends each token to one of four experts. In one batch the counts are 40,30,20,1040, 30, 20, 10. A perfectly even split would be 25,25,25,2525, 25, 25, 25.

  1. For the uneven counts, the mean is (40+30+20+10)/4=25(40 + 30 + 20 + 10)/4 = 25.
  2. The deviations are 15,5,−5,−1515, 5, -5, -15, with squares 225,25,25,225225, 25, 25, 225, summing to 500500.
  3. The sample variance is 500/3=166.7500/3 = 166.7, so s=12.91s = 12.91.
  4. The CV is 12.91/25=0.51612.91 / 25 = 0.516.
  5. For the even split the CV is 00. A larger CV means the experts are working unevenly, which is the quantity a load-balancing penalty tries to push toward zero.

Tradeoffs and failure modes

The CV is quick and scale-free, which makes it a good first look at variability. It has limits that matter in practice.

SituationProblemBetter choice
Mean near zeroCV explodes or flips signUse the standard deviation, or a measure centred on the median
Values can be negativeRatio has no clear meaningUse the standard deviation or the interquartile range
Small sampleEstimate of ss is noisy, so the CV is tooReport a confidence interval, or use more data
Skewed dataMean and standard deviation are pulled by outliersUse the median and the quartile coefficient of dispersion
Comparing variables with different naturesCV says nothing about shapeLook at the full distribution

Two common mistakes are worth naming. The first is comparing CVs of variables whose means are on different natural scales, such as a temperature in degrees Celsius, where zero is arbitrary. Dividing by the mean is only meaningful when zero means "none of the quantity". The second is treating a low CV as proof that a measurement is accurate. The CV describes spread, not bias. A precise instrument with an offset has a small CV and is still wrong.

History

The coefficient of variation was introduced by the statistician Karl Pearson in the 1890s, as part of his work on biological variation and heredity. Pearson wanted a way to compare variability between traits measured in different units, and the ratio of the standard deviation to the mean gave him one. Biologists adopted it because it let them ask whether one population was more variable than another, independent of its typical size.

The term spread through statistics textbooks in the twentieth century and into engineering, finance and quality control, where it became a standard way to report relative error and volatility. In machine learning, the same quantity has reappeared as a diagnostic. Shazeer et al. (2017) used the square of the coefficient of variation, applied to per-expert importance and load values over a batch and scaled by a hand-tuned weight, as an auxiliary loss that pushes a sparsely-gated mixture-of-experts layer toward an even split across experts. Later work such as Switch Transformers uses a different balancing loss, but the goal is the same.

Check yourself

QuestionRecall: what does the coefficient of variation divide by what?Show answer

It divides the standard deviation by the mean. The result is a ratio with no units, which is why it can be compared across variables measured on different scales.

QuestionComputation: a dataset has mean 5050 and standard deviation 1212. What is its CV, and what does it mean?Show answer

The CV is 12/50=0.2412/50 = 0.24, or 24 per cent. The spread is about a quarter of the typical value. That is a moderate relative spread, and it is the figure to compare with other datasets of different size.

QuestionWhy: why does multiplying every value by 100 leave the CV unchanged?Show answer

Multiplying the values by kk multiplies the mean by kk and the standard deviation by kk. The ratio kσ/(kμ)k\sigma/(k\mu) simplifies to σ/μ\sigma/\mu, so the factor cancels. The CV depends only on the shape of the spread relative to the centre, not on the unit used to measure it.

QuestionApplied: a monitoring team sees that the CV of request latency for one server is 0.90.9, while the others are near 0.10.1. The mean latency for that server is also close to zero. What should they conclude first?Show answer

They should not conclude yet that the server is much more variable. Because the mean is close to zero, the CV is inflated, and a small change in the mean produces a large change in the ratio. They should check whether the mean is genuinely small or near zero because of a measurement issue, and compare the raw standard deviation as well. Once the mean is reliable, the CV can be used to compare servers again.

Sources