Section 11.40

Ratio of aggregates versus aggregate of ratios

Definition

A ratio of aggregates is the total of one quantity over several trials divided by the total of another, such as all bytes delivered divided by all seconds taken. A trial is one run that yields a numerator and a denominator. An aggregate of ratios averages the trials’ individual ratios, such as their rates. Both are weighted averages of the trial ratios: each ratio counts with its own share. The ratio of aggregates weights each trial in proportion to its denominator; the mean of ratios weights every trial equally.

The idea

A car drives 60 kilometers at 60 kilometers per hour, which takes 1 hour, and then another 60 kilometers at 20 kilometers per hour, which takes 3 hours. The mean of the two speeds is (60+20)/2=40(60 + 20)/2 = 40 kilometers per hour. Yet the car covered 120 kilometers in 4 hours, an average speed of 120/4=30120/4 = 30 kilometers per hour. Both calculations are correct; they count different things equally. The mean of the speeds counts each stretch of road once. Total distance over total time counts each hour once, and the slow stretch took 3 of the 4 hours.

Experiments meet the same choice whenever each trial yields a ratio: bytes per second, processor cycles per request, packets lost per packet sent. The ratio of totals answers what the system as a whole achieved per unit of the denominator. The mean of ratios answers what a typical trial looked like, with every trial counted once however long it ran. Neither summary is right for every question. The question decides, and the estimand §11.2 entry explains how to fix that question before the data arrive.

How it works

Keep each trial’s numerator and denominator, not only their ratio: the denominators carry the weights, and a table of ratios alone cannot give the ratio of totals. Then:

  1. Decide what should count equally. If every unit of the denominator should count equally (every second, every request, every packet sent), the target is the ratio of totals. If every trial should, the target is the mean of ratios.

  2. Compute the target: the sum of the numerators divided by the sum of the denominators, or the sum of the trial ratios divided by the number of trials.

  3. Read the weights. In the ratio of totals, each trial’s weight is its denominator divided by the total denominator, so a trial with twice the denominator counts twice as much.

  4. Report the choice with the number, for example “bytes delivered per second of transfer time, all trials pooled”.

The same arithmetic explains two other common summaries.

Uncertainty must be computed over the units that were actually repeated. The trial, not the byte or the second, is the experimental unit §11.3 here: the thing that was run independently again and again. A resampling method such as the bootstrap §11.19, which recomputes the estimate on many random redraws of the data, must redraw whole trials, each numerator together with its own denominator.

Worked example

Trial A delivers 10 bytes in 1 second (s), a rate of 10/1=1010/1 = 10 bytes per second. Trial B delivers 90 bytes in 90 s, a rate of 90/90=190/90 = 1 byte per second.

The weights of the ratio of totals are the trials’ shares of the 91 seconds: 1/911/91 for A and 90/9190/91 for B, about 1.1% and 98.9%. Multiplying each rate by its weight and adding gives (1/91)×10+(90/91)×1=10/91+90/91=100/91(1/91) \times 10 + (90/91) \times 1 = 10/91 + 90/91 = 100/91, the ratio of totals again. The long, slow trial holds almost all the weight, so the result lies next to its rate of 1 byte per second.

The gap between the summaries has an exact cause, given by the formula in the next part: the longer trial is the slower one. The mean duration is (1+90)/2=45.5(1 + 90)/2 = 45.5 s. The durations deviate from it by −44.5-44.5 and +44.5+44.5 s; the rates deviate from their mean of 5.5 by +4.5+4.5 and −4.5-4.5 bytes per second. The products of matching deviations are −200.25-200.25 twice, so their mean is −200.25-200.25. Divided by the mean duration, this gives −200.25/45.5≈−4.401-200.25/45.5 \approx -4.401 bytes per second, and indeed 1.099−5.5=−4.4011.099 - 5.5 = -4.401.

The two summaries can also rank two systems in opposite orders. A second system Q runs one trial of 2 bytes in 1 s and one of 200 bytes in 100 s, a rate of 2 bytes per second in both. Its mean of ratios is 2 and its ratio of totals is 202/101=2202/101 = 2. By the mean of ratios, the first system (5.5) beats Q (2). By the ratio of totals, Q (2) beats the first system (1.099). Which system is faster depends on the question, not on the arithmetic.

Stated precisely

Let there be nn trials. For trial ii, let aia_i be its numerator, di>0d_i > 0 its denominator and ri=ai/dir_i = a_i / d_i its ratio. Write ∑i=1n\sum_{i=1}^{n} for the sum over all trials, and let A=∑i=1naiA = \sum_{i=1}^{n} a_i and D=∑i=1ndiD = \sum_{i=1}^{n} d_i be the totals. The ratio of aggregates RR and the mean of ratios MM are R=AD=∑i=1ndiDri,M=1n∑i=1nri.R = \frac{A}{D} = \sum_{i=1}^{n} \frac{d_i}{D}\, r_i, \qquad M = \frac{1}{n} \sum_{i=1}^{n} r_i. The identity for RR holds because (di/D)(ai/di)=ai/D(d_i / D)(a_i / d_i) = a_i / D, and these terms add up to A/DA / D. Dividing AA and DD both by nn leaves RR unchanged, so RR is also the ratio of the mean numerator to the mean denominator.

Let d‾=D/n\bar{d} = D / n be the mean denominator. Then R−M=1d‾⋅1n∑i=1n(di−d‾)(ri−M).R - M = \frac{1}{\bar{d}} \cdot \frac{1}{n} \sum_{i=1}^{n} (d_i - \bar{d})(r_i - M). The second factor is the covariance §15.44 of denominators and ratios across the trials: the mean product of their deviations from their means, which is positive when trials with large denominators tend to have large ratios. So R>MR > M exactly when the covariance is positive, R<MR < M exactly when it is negative, and R=MR = M when it is zero, which includes the case of equal denominators. When every ai>0a_i > 0, RR is also a weighted harmonic mean of the ratios, with the numerators as weights: R=A/∑i=1n(ai/ri)R = A / \sum_{i=1}^{n} (a_i / r_i), because ai/ri=dia_i / r_i = d_i.

These identities assume only positive denominators, and a numerator and denominator measured over the same interval with the same counting rule in each trial. Which of RR and MM is the estimand is a decision about the question, not a consequence of the identities.

Limits and common mistakes

A zero denominator makes that trial’s ratio undefined, and a tiny one makes it huge. A trial that delivered 1 byte in 1 millisecond has a rate of 1,000 bytes per second and can dominate a mean of ratios, while the ratio of totals barely notices it. Decide before the analysis how such trials count.

One very long trial can decide the ratio of totals alone. Report the trial denominators along with the summary.

The same choice hides inside percentages. The mean of per-run loss percentages is a mean of ratios; total packets lost divided by total packets sent is a ratio of totals.

Neither summary is the geometric mean §11.39 of the ratios, the nnth root of the product of nn ratios. That third summary, used mainly for ratios of normalized performance, is treated in the geometric mean entry.

Choosing the summary after seeing which one favors a system is a biased report. Fix the estimand first.

Questions answered

Which estimate weights a long trial more heavily?

The ratio of aggregates, the total numerator divided by the total denominator, weights a long trial more heavily when time is the denominator, as in total bytes divided by total seconds. It equals an average of the per-trial rates in which each trial’s weight is its share of the total time. A trial that lasted 90 of 91 seconds therefore has weight 90/9190/91, about 99%. The mean of the per-trial rates gives every trial the same weight, 1/21/2 each for two trials, however long each lasted.

In general the ratio of aggregates weights each trial by whatever is in the denominator: by bytes, for example, if the ratio is seconds per byte. Both are correct calculations of different quantities, so a report must state which one it gives.

Related entries: Estimand and estimator (§11.2), Effect size (§11.24), Geometric mean (§11.39), Finite-window rate (§11.41), Bootstrap (§11.19).