Put the Warehouse at the Median, Not at the Average
Published 11/17/2026 · 3 min read · Business tools
Daniel Okonkwo — Front-end developer and tech writer at OneKitly
Web performance · File formats
Checked against 2 sources
The median is the value that minimises the total distance to every point, and the mean is the value that minimises the total squared distance. For deliveries the first is what matters, because a lorry pays for kilometres and not for kilometres squared. Five shops along a road at 12, 18, 20, 25 and 30 have a mean of 21 and a median of 20; placing the depot at the median costs 25 km of one-way travel across all five, while the mean costs 26. The gap is small here and grows with the skew, which is exactly the situation where the two measures separate.
Five shops at km 12, 18, 20, 25 and 30 average 21 and have a median of 20. Driving from 20 costs 25 km a round; from 21 it costs 26.
Why the median is the flat spot
Move the depot one kilometre in either direction and every shop on that side gets a kilometre closer while every shop on the other side gets a kilometre further. The total only improves while there are more shops ahead than behind, and it stops improving exactly when the two sides are equal — which is the definition of the median. With an even number of points the whole segment between the middle two is equally good, which is why a depot anywhere in that stretch costs the same and the choice can be made on rent instead.
When the mean is the right answer instead
Whenever the cost grows with the square of the distance rather than with the distance. A network of springs settles at the mean of its anchor points, an estimator fitted by least squares lands on the mean, and a physical centre of mass is the mean of the positions. The choice between the two is not a matter of taste but of what the penalty function looks like, and asking what a unit of distance actually costs settles it every time. Delivery kilometres are linear; structural strain is quadratic.
| Depot at km | Total distance | Note |
|---|---|---|
| 19 | 26 km | Below the median |
| 20 | 25 km | The median |
| 21 | 26 km | The mean |
Worked with our own calculator
Median calculator
Given
- Numbers
- 12, 18, 20
Result
- Median
- 18
- Min
- 12
- Max
- 20
These figures are produced by the calculator below, not typed in by hand — they are recomputed whenever the tool changes.
Run it on your own figures →Frequently asked questions
- Does this work in two dimensions?
- The idea survives and the arithmetic does not. On a plane the point minimising total distance is called the geometric median, and it has no formula — it is found by iteration. Taking the median of the eastings and the median of the northings separately gives a different point, which is optimal only if travel is restricted to a grid of streets. City logistics uses the grid version for exactly that reason, and open-country problems use the iterative one.
- What if the shops have different delivery volumes?
- Then the answer is the weighted median: sort the shops by position and walk along adding volumes until you pass half the total. A shop taking three deliveries a week counts three times in that walk. The plain median is the special case where every point weighs the same, and forgetting the weights is how a depot ends up conveniently near the smallest customer. Weighted or not, the rule is about counting deliveries on each side rather than averaging positions.
Articles you may find interesting
All guides →Related tools
Sources
Spotted a mistake in this article?