Probability & Statistics · Mean and median

Mean and median

The mean is the sum of the values divided by how many there are; the median is the middle value once they are sorted, or the midpoint of the middle two when there is an even number. The mean balances the distances on its two sides and the median balances the counts, so a far point pulls the mean but moves the median only if it changes the middle values.

Mean and median in this visualization

Each value is an ink dot on a number line; equal values stack. The yellow triangle under the line is the mean xˉ\bar{x}, the dashed line is the median MM. When you move a value, faint marks record the earlier positions. When an arrow appears, it shows how far the mean moved.

The mean: its distances on the two sides cancel
xˉ=1n∑i=1nxi,∑i=1n(xi−xˉ)=0\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i, \qquad \sum_{i=1}^{n} (x_i - \bar{x}) = 0

What does the mean balance? Distances. The values to its left lie, in total, exactly as far from it as the values to its right, which is why the triangle works like the fulcrum of a seesaw. Move one value by Δ\Delta and the sum changes by Δ\Delta, so the mean moves by Δ/n\Delta/n: drag 7 out to 50 among nine values and the mean shifts by 43/9≈4.7843/9 \approx 4.78. However far a value goes, the mean follows.

What does the median balance? Counts. Sorted, it is the middle value, or the midpoint of the middle two when nn is even, so at most half the values lie below it and at most half above. As long as the middle value, or the middle two, stay where they are, the median does not move, however far an outer value is dragged. Drag a value through the middle, though, and the median can move with it. To lift it above every original value, the middle value (for even nn, the upper of the middle two) and every value above it must be changed values above the old maximum. With nn fixed, that takes at least ⌈n/2⌉\lceil n/2 \rceil changes; with nine values, five.

Why are both called a center? Turn on Try a center and pick a point cc. The lower plot shows two average distances from cc to the values. The solid one, the root mean square distance, satisfies RMS(c)2=σ2+(c−xˉ)2\mathrm{RMS}(c)^2 = \sigma^2 + (c - \bar{x})^2: it is lowest at the mean, where it equals the standard deviation σ\sigma (the variance taken with denominator nn). The dashed one, the mean absolute distance, is made of straight pieces. Between two values its slope is (L−R)/n(L - R)/n, where LL values lie left of cc and RR right: stepping right moves you away from the LL values and toward the RR values. It is lowest wherever neither side has more than half the values, and the median is always one of those places. When nn is even and the middle two values differ, that is a flat stretch between them, and the median is its midpoint.

Things to notice

  • With two clusters, the mean and the median can both land in the gap between them, where there is no value at all.
  • A long right tail usually puts the mean above the median, but not always.
  • A trimmed mean drops the same number of values from each end and averages the rest. It weakens the extremes, but it need not land between the mean and the median.

Controls

  • Click an empty part of the dot plot to add a value. Delete removes the selected one.
  • A dragged dot stops at the edge of the view. To send it further, type its new value under Selected.

Related