Sum of Squares Calculator
Enter a list of numbers to find the sum of squares instantly. Choose statistical mode (sum of squared deviations from the mean, used in variance, ANOVA, and regression) or algebraic mode (sum of each value squared). You also get the count, mean, variance, and standard deviation, plus a full step-by-step breakdown so you can follow every calculation.
What is the sum of squares?
The sum of squares (SS) measures how spread out a set of numbers is. In its most common statistical form it equals the sum of the squared difference between each data value and the group mean: SS = Σ(xᵢ - x̅)². Squaring the differences ensures that values above and below the mean both contribute positively, so they cannot cancel each other out. The result is always zero or greater, reaching zero only when every value in the dataset is identical to the mean. The larger the SS, the more spread out the data. Dividing SS by (n - 1) gives the sample variance; dividing by n gives the population variance. Taking the square root of either gives the corresponding standard deviation.
Statistical SS vs. algebraic SS
There are two common interpretations of "sum of squares." The statistical version, SS = Σ(xᵢ - x̅)², subtracts the mean from each value before squaring. This is the number that variance and standard deviation are built on, and it appears throughout hypothesis testing, ANOVA, and linear regression. The algebraic version, SS = Σxᵢ², simply squares each raw value and adds them up, with no reference to the mean. The two are related through the computational shortcut: Σ(xᵢ - x̅)² = Σxᵢ² - n * x̅², which lets you compute the statistical SS without first finding every individual deviation. Use statistical mode whenever you need variance, standard deviation, or any ANOVA or regression quantity. Algebraic mode is useful for shortcut formulas and in contexts such as the sum of the first n consecutive squares.
Sum of squares in ANOVA and regression
ANOVA (Analysis of Variance) decomposes the total sum of squares into two parts. SS Between (also called SS Treatment or SS Model) measures how much each group mean differs from the grand mean, capturing the effect of the grouping factor. SS Within (also called SS Error or SS Residual) captures how much individual observations vary within each group around that group's own mean. The key identity is: SS Total = SS Between + SS Within. In simple linear regression the same split applies: SS Total = SS Regression + SS Residual. SS Regression (also called SS Explained) is the variation accounted for by the fitted line, while SS Residual is the leftover error. The ratio SS Regression / SS Total equals R-squared, the proportion of variance explained by the model. Understanding these decompositions is the foundation of both ANOVA F-tests and regression inference.
How to calculate the sum of squares by hand
To find the statistical sum of squares manually: first compute the mean by adding all values and dividing by n. Then, for each data point, subtract the mean and square the result. Finally, add all those squared differences together. For example, with the dataset 4, 7, 13, 2, 1: the mean is (4 + 7 + 13 + 2 + 1) / 5 = 5.4. The squared deviations are (4 - 5.4)² = 1.96, (7 - 5.4)² = 2.56, (13 - 5.4)² = 57.76, (2 - 5.4)² = 11.56, (1 - 5.4)² = 19.36. Summing those gives SS = 1.96 + 2.56 + 57.76 + 11.56 + 19.36 = 93.2. For the algebraic version with the same data: 4² + 7² + 13² + 2² + 1² = 16 + 49 + 169 + 4 + 1 = 239.
Sum of squares variants and their uses
| SS Type | Formula | Used in |
|---|---|---|
| Statistical (total) | Σ(xᵢ - x̅)² | Variance, std dev, ANOVA total |
| Algebraic | Σxᵢ² | Variance shortcut formulas |
| SS Between (ANOVA) | Σnⱼ(x̅ⱼ - x̅)² | Between-group variation in ANOVA |
| SS Within (ANOVA) | ΣΣ(xᵢⱼ - x̅ⱼ)² | Within-group (error) variation in ANOVA |
| SS Regression | Σ(ŷᵢ - x̅)² | Explained variation in linear regression |
| SS Residual | Σ(yᵢ - ŷᵢ)² | Unexplained variation (regression error) |
Different SS formulas apply in different statistical contexts. All build on the same core idea of squaring differences.
Frequently asked questions
What does the sum of squares measure?
The statistical sum of squares measures total variability in a dataset. It answers the question: how far do the individual values stray from the mean, in total, when each distance is squared? A SS of zero means every value equals the mean. A large SS means the data is widely spread. Dividing SS by (n - 1) converts it into the sample variance, the most widely used single measure of spread.
What is the difference between statistical SS and algebraic SS?
Statistical SS = Σ(xᵢ - x̅)² subtracts the mean from each value before squaring. It measures dispersion around the mean and is used for variance, standard deviation, ANOVA, and regression. Algebraic SS = Σxᵢ² simply squares each raw value and sums them, with no mean subtraction. The two are connected by the identity Σxᵢ² = SS + n * x̅², so you can switch between them if you know the count and mean.
How is sum of squares used in ANOVA?
One-way ANOVA splits the total sum of squares (SS Total = Σ(xᵢ - grand mean)²) into two components: SS Between, which captures how much the group means differ from each other, and SS Within, which captures variation within each group. Dividing each by its degrees of freedom gives the mean squares. The F-statistic is MS Between / MS Within. A large F indicates that between-group differences are unlikely to be due to chance alone.
How is sum of squares used in linear regression?
In regression, SS Total = SS Regression + SS Residual. SS Regression (also called SS Explained) is the portion of total variability that the fitted line accounts for. SS Residual is the leftover variation not explained by the model. R-squared equals SS Regression / SS Total, and it tells you what fraction of the total variance the model explains. The residual mean square (SS Residual / degrees of freedom) estimates the variance of the error term.
Why do we square the deviations instead of just summing them?
If you simply summed the deviations (xᵢ - x̅) without squaring, positive and negative deviations would cancel out and the total would always equal zero, giving you no information about spread. Squaring makes all deviations positive and also penalizes larger deviations more heavily, which is the mathematically natural choice because it leads to the least-squares estimates that minimize prediction error in regression.
What does SS divided by (n - 1) give, and why not n?
Dividing SS by (n - 1) gives the sample variance, s². The denominator (n - 1) is called Bessel's correction. When estimating population variance from a sample, we use the sample mean rather than the (unknown) population mean, and this introduces a small downward bias in SS. Dividing by (n - 1) instead of n corrects for that bias, making the sample variance an unbiased estimator of the population variance. If you know you have the entire population, dividing by n (population variance) is appropriate instead.
Can the sum of squares be negative?
No. Because every term in Σ(xᵢ - x̅)² is a squared real number, it is always zero or positive. The same holds for the algebraic SS = Σxᵢ². If you ever compute a negative SS it signals an arithmetic error, often a sign mistake when computing deviations or a rounding problem in an intermediate step.