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 kilometers per hour. Yet the car covered 120 kilometers in 4 hours, an average speed of 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:
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.
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.
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.
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.
The pooled mean of events. When all events from several devices are averaged together, the result is a ratio of totals: a device’s numerator is the sum of its values and its denominator is its number of events. Each device’s own mean is therefore weighted by its number of events, so a device with 100 events outweighs a device with 1.
Equal numerators or equal denominators. When every trial has the same numerator, such as the same file size or the same distance, the ratio of totals equals the harmonic mean of the trial ratios: the number of trials divided by the sum of the reciprocals of the ratios. The car journey is this case: kilometers per hour. When every trial has the same denominator, such as the same duration, the ratio of totals equals the ordinary mean of ratios.
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 bytes per second. Trial B delivers 90 bytes in 90 s, a rate of byte per second.
Mean of ratios: bytes per second. Each trial has weight .
Ratio of totals: bytes per second.
The weights of the ratio of totals are the trials’ shares of the 91 seconds: for A and for B, about 1.1% and 98.9%. Multiplying each rate by its weight and adding gives , 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 s. The durations deviate from it by and s; the rates deviate from their mean of 5.5 by and bytes per second. The products of matching deviations are twice, so their mean is . Divided by the mean duration, this gives bytes per second, and indeed .
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 . 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 trials. For trial , let be its numerator, its denominator and its ratio. Write for the sum over all trials, and let and be the totals. The ratio of aggregates and the mean of ratios are The identity for holds because , and these terms add up to . Dividing and both by leaves unchanged, so is also the ratio of the mean numerator to the mean denominator.
Let be the mean denominator. Then 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 exactly when the covariance is positive, exactly when it is negative, and when it is zero, which includes the case of equal denominators. When every , is also a weighted harmonic mean of the ratios, with the numerators as weights: , because .
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 and 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 th root of the product of 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 , about 99%. The mean of the per-trial rates gives every trial the same weight, 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).