MATTHEWLAB
Software engineering

Average first, convert later? The order changes the answer.

The average of converted measurements can differ from the conversion of their average. A two-number example makes the choice visible.

Two measurement paths show conversion before averaging and averaging before conversion.

A sensor produces several readings. Take the average, apply the conversion formula, display a calmer number. It sounds reasonable until the conversion is nonlinear.

The Korean note began with a discussion of a pressure-monitor project. That project does not establish a universal rule for every sensor. A smaller calculation is enough to show why the order deserves attention.

Two readings are enough

Use a hypothetical conversion f(x) = 10^x and the inputs zero and two. Converting each reading gives one and one hundred. Their arithmetic mean is 50.5. Averaging the original inputs gives one; converting that average gives ten.

mean(f(0), f(2)) = (1 + 100) / 2 = 50.5
f(mean(0, 2))    = 10^1             = 10

Both calculations use the same inputs and formula. They summarize different things. In this particular exponential example, ten is also the geometric mean of the two converted values. The example uses invented inputs; it is not a calibration result for a physical sensor.

With an affine conversion such as f(x) = 2x + 3, the ordinary arithmetic mean does commute with conversion. That contrast is useful. The conclusion is about the transformation and the quantity being summarized, rather than a general instruction to always convert first.

An average discards choices you may need later

If all that remains is an input average of one, the original pair could have been zero and two, or one and one. Under the exponential conversion, those pairs do not produce the same mean converted value. The stored average is insufficient to reconstruct that result.

That is a reason to choose a retention rule deliberately, not to save every raw reading forever. A display for short spikes, a trend report and a long-term storage budget may call for different records.

Time introduces another choice. If observations arrive at irregular intervals, an average over observations is not automatically an average over time. Missing observations introduce a gap; filling it with zero creates a measured-looking value that was never observed.

I would put the unit, interval and averaging method beside the chart before polishing its colors. A label saying only “average pressure” can conceal a surprising amount of engineering.

한국어 글: 평균부터 낸 센서값, 같은 숫자가 아닐 수도 있다