How the Sum of Products (SP) Works
In statistics, the sum of products (SP), also called the sum of products of deviations, is a building-block statistic used to describe how two paired variables, X and Y, vary together. For each pair of values, it measures how far X is from its own mean and how far Y is from its own mean, then multiplies those two deviations and adds the results across every pair: SP = Σ(Xi − X̄)(Yi − Ȳ). When both variables tend to be above (or both below) their means at the same time, the products are positive and SP is large and positive. When one variable tends to be high while the other is low, the products are negative and SP is negative. SP near zero suggests little linear relationship.
Deviation formula vs. computational formula
Computing the deviation formula directly requires finding X̄ and Ȳ first, then subtracting them from every value. In practice this calculator (and most textbooks) uses the algebraically equivalent computational formula, which needs only running totals: SP = ΣXY − (ΣX)(ΣY)/n, where n is the number of pairs, ΣXY is the sum of each X times its paired Y, and ΣX and ΣY are the simple sums of each list. Both formulas always give the same number — the computational version is just easier to calculate by hand or in a single pass through the data.
From SP to covariance, correlation, and regression
SP rarely stands alone — it is the numerator in several related statistics. Dividing SP by n − 1 gives the sample covariance; dividing by n gives the population covariance. Dividing SP by the square root of the product of the sums of squares, r = SP / √(SSx · SSy) — where SSx = ΣX² − (ΣX)²/n and SSy = ΣY² − (ΣY)²/n — gives the Pearson correlation coefficient r, a unit-free number between −1 and 1. And dividing SP by SSx alone gives the slope of the least-squares regression line of Y on X.
Common mistakes
- Mismatched list lengths: X and Y must have exactly the same number of values, entered in the same order, since each pair is (Xi, Yi).
- Confusing SP with ΣXY: ΣXY is just the raw sum of products; SP subtracts off the part explained by the two means, so the two numbers are usually quite different.
- Too few data points: SP, covariance, and correlation all need at least two pairs — a single point has no variation to measure.
- Ignoring zero variance: if every X value (or every Y value) is identical, its sum of squares is zero and the correlation coefficient becomes undefined, even though SP itself may still be computable.
Real-world applications
- Computing the Pearson correlation coefficient between two variables in a statistics or research report.
- Finding the slope of a least-squares regression line, since b = SP/SSx is the standard textbook formula.
- Estimating covariance between two assets or measurements as an intermediate step before further analysis (such as portfolio variance).
- Classroom and homework exercises that build correlation and regression from first principles rather than a single "black box" formula.