The Daily Reckoning
Why Does Squaring Every Error Choose the Average?
The arithmetic mean is more than a familiar recipe: it is the unique number that makes the total squared distance to a dataset as small as possible.
- Difficulty
- Foundational
- Area
- Numbers, statistics, and optimization
- Reading time
- 9 minutes
- Prerequisites
- Arithmetic mean · Squaring positive and negative numbers · Basic algebra with sums
Three instruments report the same quantity as , , and . You must replace the three readings with one number. Which number should you choose?
The middle reading, , is tempting. The arithmetic mean is
Neither answer is universally correct. The choice depends on how you charge for a miss. If an estimate receives a penalty of for missing a reading , then wins—and no other estimate ties it.
That statement is not a convention about averages. It is a theorem.
Turn every miss into a square
Let the data be the real numbers . The symbol is the number of data values. For any proposed representative value , define the sum of squared errors
The index runs from through . The Greek capital letter means to add the terms that follow it. Each difference is a residual: the signed distance from the estimate to the observation . Squaring makes every contribution nonnegative and makes a miss twice as large cost four times as much.
The arithmetic mean of the data is
The bar in is read “ bar.” The central claim is precise:
For any finite list of real numbers, has its unique minimum at .
The diagram below uses the readings , , and . Each horizontal lane shows one residual. The lower plot shows the total squared error for every possible estimate between and .
Squared-error sounding board
Move one estimate against three readings
The curve is a parabola. Its lowest point sits directly under , the mean. Moving one unit away raises the total by ; moving two units away raises it by .
Why the mean must win
The proof needs one fact about the mean: the signed deviations from it add to zero.
Now split each residual around the mean:
Square both sides and add over all observations:
The middle term vanishes because . The final summand is the same for every , so adding it times gives . Therefore
This identity settles the contest. The first term, , does not depend on . The second term is a nonnegative square multiplied by the positive number . It equals zero only when .
Every move away from the mean adds exactly to the minimum possible squared error.
Worked example: , , and
For the three readings, the mean is .
Step 1: calculate the minimum squared error.
Step 2: write the full error curve. There are readings, so the boxed identity gives
Step 3: test the tempting choice .
A direct calculation agrees:
Choosing helps the middle observation, but the five-unit miss from costs . Moving the estimate from to increases two smaller squared residuals while shrinking the largest one enough to reduce the total from to .
The penalty chooses the center
The mean wins only after we decide to square the residuals. Suppose the penalty were the sum of absolute distances,
For the same three readings,
while
Absolute error chooses the median, , rather than the mean, . Squared error gives extra influence to a distant value because large residuals grow quadratically. That sensitivity is useful when large misses are especially costly, but it also means that an outlier can pull the mean sharply.
The phrase “best representative” is incomplete until the penalty is named.
From discordant observations to least squares
Astronomy and geodesy made this optimization problem urgent long before electronic computers. Surveyors and astronomers often had more observations than unknown quantities, and measurements disagreed slightly. A calculation needed one set of parameters that reconciled the observations without pretending that every reading was exact.
Adrien-Marie Legendre first published the method of least squares in 1805 in Nouvelles méthodes pour la détermination des orbites des comètes, a work on determining comet orbits. A contemporary Royal Astronomical Society obituary preserved by MacTutor connects the method to Legendre’s work with discordant astronomical observations. The same account describes his earlier participation in the triangulation joining the Greenwich and Paris observatories and his later work on the commission that deduced the length of the metre. Precision was tied to observatories, national surveys, and the new metric standard—not merely to a clean classroom table.
Carl Friedrich Gauss published a probabilistic treatment in 1809 and claimed that he had used the method since 1795. Legendre objected to the priority claim. Modern histories distinguish the achievements: Legendre published the method first; Gauss later connected least squares to a probability model for observational error. A recent history of Gauss’s 1809 argument explains that under normally distributed errors, maximizing likelihood leads to minimizing squared deviations.
The small theorem in this lesson is the constant-model case of least squares. A National Bureau of Standards measurement manual states the connection directly: using the arithmetic mean of repeated measurements fits one constant to the data by least squares.
Where the theorem works today
The National Institute of Standards and Technology description of least squares extends the same idea from one constant to lines and more complicated models. Instead of choosing , a regression calculation chooses model parameters that minimize the sum of squared residuals.
The theorem also appears inside k-means clustering, an algorithm that groups data points around centers. The scikit-learn clustering guide defines each cluster center as the mean of the points assigned to that cluster and measures the cluster by its within-cluster sum of squares. Once the group memberships are fixed, the theorem proves why the mean is the best center under that squared-distance rule.
Neither application makes squared error mandatory. Engineers and statisticians choose other penalties when outliers, asymmetry, or domain-specific costs matter. The theorem says what follows from one particular choice: once squared distance is the score, the mean is forced.
Try the identity
Problem 1
The four observations are , , , and . Find the mean, the minimum sum of squared errors, and .
Reveal the solution
The mean is
At the mean,
Because , the identity gives
Substitute :
Problem 2
A sensor reports once and three times. Without expanding four squared residuals, find the constant that minimizes their total and calculate the minimum total squared error.
Reveal the solution
Treat the readings as the list . Its mean is
The minimizing constant is therefore . Its squared error is
The three repeated readings pull the mean three times as strongly as the single reading. The same calculation can be written as a weighted least-squares problem with weights and .
The idea to keep
The arithmetic mean is the balance point for squared distance. For any estimate ,
so leaving the mean adds a precisely known, nonnegative penalty.
To continue, Why Do Averages Keep Drawing Bell Curves? studies what happens when means are formed repeatedly, How Can One Treatment Win Every Group but Lose Overall? shows how unequal weights can reverse an average, and How Can a Tangent Line Find √2? introduces a different route to a minimum.
Sources
- National Institute of Standards and Technology, “Least Squares”, the general least-squares criterion and its use in regression.
- National Bureau of Standards, Experimental Statistics, section on fitting constants by least squares and the arithmetic mean.
- MacTutor History of Mathematics, “Adrien-Marie Legendre — RAS obituary”, Legendre’s astronomical, geodetic, and least-squares work.
- Jan R. Magnus, “Gauss on least-squares and maximum-likelihood estimation”, Archive for History of Exact Sciences 76 (2022), 567–576.
- scikit-learn, “Clustering”, the k-means objective and mean-valued cluster centers.