Section 11.24

Effect size

Definition

An effect size is a number that states how large a difference or relationship is, as opposed to whether it can be detected. It takes one of three forms: an absolute difference in the measurement’s own units, such as 2 milliseconds; a relative change, which divides the difference by a baseline value and is often written as a percentage; or a standardized difference, which divides it by a standard deviation §11.14, the typical spread of the measurements. An effect size means something only with its direction, baseline and units stated.

The idea

Two code changes each pass a hypothesis test §11.22 with a p-value §11.23 below 0.001. One saves 1 microsecond on a 10-millisecond operation; the other saves 3 milliseconds. The p-values cannot tell the two apart, because a p-value mixes the size of an effect with the amount and the noise of the data: a tiny effect measured often enough reaches a tiny p-value. The effect size is the part that says how much changed, and it decides whether the change matters for a deadline, a battery or a user.

Relative effects need special care, because their size depends on the denominator. A delay that grows from 1 to 2 microseconds has grown by 100%; a delay that grows from 1000 to 1001 microseconds has grown by 0.1%. Both grew by the same 1 microsecond. A percentage says as much about the baseline as about the change.

How it works

An effect is reported in five parts.

  1. The two values compared: the baseline BB, the reference condition, and the treatment TT, the new condition, each with its units and with the summary used, such as the mean over runs, the median §11.13 or the 99th percentile §11.16. The effect on the median and the effect on the slowest 1% of requests can differ greatly.

  2. The direction: which sign is an improvement. For a latency, smaller is better; for a throughput, larger is better.

  3. The absolute difference T−BT - B, in the measurement’s units.

  4. A relative measure, if useful, with its denominator named.

  5. The uncertainty of the effect, usually a confidence interval §11.18: a range computed from the data by a rule that, over repeated experiments, covers the true effect in a stated fraction of them, such as 95%.

For a duration, four relative measures are common.

These are four different functions of the same two numbers, and the words “faster” and “slower” do not say which one was used.

A standardized effect divides the difference of two means by a standard deviation ss of the measurements: d=(x‾T−x‾B)/sd = (\bar x_T - \bar x_B)/s, where x‾T\bar x_T and x‾B\bar x_B are the means of the treatment and baseline groups. The best known is Cohen’s dd, which uses the standard deviation pooled from both groups. It has no units, so it can compare studies that measured different things. Jacob Cohen proposed 0.2, 0.5 and 0.8 as rough marks of small, medium and large effects in the behavioral sciences; these marks carry no meaning for measurements of computer systems.

Worked example

A request takes 10 milliseconds (ms) on the baseline system and 8 ms on the new one.

Measured against the new system, the old one takes (10−8)/8=0.25(10 - 8)/8 = 0.25, that is 25%, more time. So “the new system is 20% faster” and “the old system is 25% slower” describe the same two numbers.

The denominator decides the percentage. One delay grows from 1 to 2 microseconds: the absolute change is 1 microsecond and the relative change is 1/1=11/1 = 1, or 100%. Another delay grows from 1000 to 1001 microseconds: the absolute change is again 1 microsecond, but the relative change is 1/1000=0.0011/1000 = 0.001, or 0.1%. The factor of 1000 between the two percentages comes entirely from the baselines.

A small denominator also makes the percentage unstable. Suppose a timer reports whole microseconds and each true value lies within 0.5 microsecond of its reading. The readings 1 and 2 then mean a true baseline between 0.5 and 1.5 and a true treatment between 1.5 and 2.5 microseconds. The relative change can be as small as (1.5−1.5)/1.5=0(1.5 - 1.5)/1.5 = 0 and as large as (2.5−0.5)/0.5=4(2.5 - 0.5)/0.5 = 4: anywhere from 0% to 400%. For the readings 1000 and 1001 the same timer gives a relative change from (1000.5−1000.5)/1000.5=0(1000.5 - 1000.5)/1000.5 = 0 up to (1001.5−999.5)/999.5≈0.002(1001.5 - 999.5)/999.5 \approx 0.002: from 0% to 0.2%. In both cases the absolute change lies between 0 and 2 microseconds; only the relative statement swings widely.

Stated precisely

Let B>0B > 0 be the baseline value and T>0T > 0 the treatment value, in the same units. Then Δ=T−B,r=T−BB,S=BT\Delta = T - B, \qquad r = \frac{T - B}{B}, \qquad S = \frac{B}{T} are the absolute difference Δ\Delta (capital delta), in the units of BB, the relative change rr and the speedup SS. The last two have no units, because the units cancel. They are linked by S=1/(1+r)S = 1/(1 + r), and the relative reduction is −r=1−1/S-r = 1 - 1/S. For B=10B = 10 and T=8T = 8: Δ=−2\Delta = -2, r=−0.2r = -0.2, S=1/0.8=1.25S = 1/0.8 = 1.25 and 1−1/1.25=0.21 - 1/1.25 = 0.2. If B=0B = 0, rr is undefined; if the uncertainty range of BB includes 0, the uncertainty range of rr has no bound.

The standardized difference that dd estimates is (μT−μB)/σ(\mu_T - \mu_B)/\sigma, where μT\mu_T and μB\mu_B (mu) are the true means of the two conditions and σ\sigma (sigma) is a chosen standard deviation. Its value depends on which spread σ\sigma measures: the spread between requests, between runs or between devices. Every quantity in this section is a property of the conditions compared; a value computed from data is an estimate of it and is complete only together with its confidence interval.

Limits and common mistakes

A percentage without its baseline cannot be interpreted. Give the baseline and the treatment values as well.

“50% faster” is ambiguous. It can mean a time reduced by 50%, which is a speedup of 2, or a rate of work increased by 50%, which multiplies the time by 1/1.5≈0.6671/1.5 \approx 0.667. Write the formula.

A small p-value does not mean a large effect, and a large estimated effect is not established while its confidence interval is wide.

Combining relative effects over several workloads is a separate choice: the arithmetic mean §11.12 of the ratios, their geometric mean §11.39 and the ratio of the total times can disagree. The Geometric mean entry and the Ratio of aggregates versus aggregate of ratios §11.40 entry treat this choice.

A standardized effect depends on the spread chosen. Two studies with different noise give different values of dd for the same physical change, and Cohen’s labels are not universal.

An average effect does not hold for every case. A mean improvement can hide a slowdown on some workloads or among the slowest requests.

Practical importance needs a reference. Saving 2 ms matters against a 10 ms deadline and hardly at all against a 10-second one.

Questions answered

Is a relative improvement large because the denominator is very small?

It can be, and the check is to compare the relative improvement with the absolute one. A relative improvement divides the absolute change by a baseline, so the same absolute change gives a large percentage on a small baseline and a small percentage on a large one: 1 microsecond is 100% of a 1-microsecond baseline but 0.1% of a 1000-microsecond baseline. A small baseline also magnifies measurement error. If each reading of a 1-microsecond baseline and a 2-microsecond treatment can be off by 0.5 microsecond, the true relative change can be anywhere from 0% to 400%.

Report the baseline, the treatment value, the absolute difference with its units and its uncertainty, and then the percentage with its denominator named. Judge importance by the absolute change measured against the resource that matters, such as a deadline or a time budget.

Related entries: Hypothesis test (§11.22), Geometric mean (§11.39), Ratio of aggregates versus aggregate of ratios (§11.40), Confidence interval (§11.18), p-value (§11.23).