Field note · October 16, 2025
humidity_pct by status: a 4% spread
Real group means for one column across 3 segments, and what the pooled average conceals.
Breaking humidity_pct down by status on sensor-telemetry, because the headline average is 40.91 and no segment is actually there.
fault— mean 42.41, median 42.40 (124 rows)warn— mean 41.82, median 41.80 (482 rows)ok— mean 40.83, median 40.80 (7,394 rows)
Top to bottom that is 42.41 against 40.83, a spread of 3.9%. The pooled average is 40.91.
select status,
count(*) as rows,
round(avg(humidity_pct)::numeric, 2) as mean,
percentile_cont(0.5) within group (order by humidity_pct) as median
from sensor_telemetry
group by 1
order by mean desc;The groups are close enough that the pooled average is a fair summary. That is worth confirming rather than assuming: the check costs one query and the failure mode is invisible.
Notice the mean and median columns disagree only slightly here. Always compute both in the group-by. The comparison between them per segment is free and tells you whether you are looking at a level difference or a tail difference.
This is the setup for Simpson's paradox — the case where every segment moves one way and the total moves the other.