Sum of Squares Calculator
The sum of squares adds up the squared differences between each value and the mean. It is the foundation of variance, standard deviation and regression.
How to use the sum of squares calculator
Paste your data to get the sum of squared deviations, the sum of squared values, the mean and the count.
Sum of squares formulas
SS = Σ(x − x̄)² = Σx² − n x̄²
Worked example
Data: 2, 4, 4, 4, 5, 5, 7, 9 (mean = 5)
- Σx² = 232
- SS = 232 − 8 × 25 = 32
- Population variance = 32 ÷ 8 = 4 → σ = 2
Where sums of squares are used
| Use | How |
|---|---|
| Variance and SD | Variance = SS ÷ (n − 1) |
| Regression | Total SS = explained SS + residual SS |
| R² | R² = 1 − residual SS ÷ total SS |
| ANOVA | Splits total SS into between-group and within-group parts |
| Least squares | Fits the line that minimises residual SS |
Two ways to compute
Definition formula: SS = Σ(x − x̄)². Clear and numerically stable.
Computational formula: SS = Σx² − (Σx)² ÷ n. Faster by hand, but can lose precision when values are large and close together.
Example with 2, 4, 6, 8: Σx = 20, Σx² = 120, so SS = 120 − 400 ÷ 4 = 20. By definition: (−3)² + (−1)² + 1² + 3² = 20.
Regression example
For a fitted line, the residual sum of squares adds up the squared vertical distances between the points and the line. A smaller residual SS relative to the total SS means a better fit (higher R²).
Degrees of freedom
Each SS comes with degrees of freedom: n − 1 for total SS around the mean, n − 2 for residuals in simple linear regression. Mean squares (SS ÷ df) are what F-tests compare.
Frequently asked questions
What is the sum of squares?
In statistics it usually means the sum of squared deviations from the mean, Σ(x − x̄)² — the basis of variance and ANOVA.
How does it relate to variance?
Sample variance = SS ÷ (n − 1); population variance = SS ÷ n.
Why square the deviations?
So negative and positive deviations don't cancel out, and so larger deviations count more.
What is the sum of squares used for?
It measures total variation around the mean and is the basis for variance, standard deviation, regression and ANOVA.
How do I get variance from the sum of squares?
Divide by n − 1 for a sample or by n for a population.