ABWex / Tools / Pooled standard deviation calculator

Pooled standard deviation calculator

Pooling two standard deviations is one line of algebra, and most calculators stop there. The number is only useful because of what it feeds, so this one also runs the test it feeds and tells you when pooling is the wrong thing to do.

Enter your two groups

Give each group a size, a mean and a standard deviation. If you have the raw numbers instead, paste them and the summary statistics are computed for you.

Group A

Group B

The formula, and the assumption hiding inside it

The pooled standard deviation is the square root of a weighted average of the two sample variances, weighted by degrees of freedom.

s_p = sqrt( ( (n1 - 1) s1^2 + (n2 - 1) s2^2 ) / (n1 + n2 - 2) )

Read the weighting carefully, because it is where the assumption lives. Each variance is weighted by its own degrees of freedom, so the larger sample dominates the pooled figure. That is the right thing to do only if both groups are drawn from populations with the same variance. Pooling is not an averaging convenience. It is a claim that one number describes the spread of both groups.

When that claim is false, the pooled value sits between the two real spreads and describes neither. The calculator above reports the ratio of the two sample variances so you can see how strong the claim is before you rely on it.

What the pooled value is actually for

On its own the pooled standard deviation answers no question. It exists to feed three things, and the calculator returns all three rather than making you carry the number somewhere else.

QuantityFormulaWhat it tells you
Student t(m1 - m2) / (s_p sqrt(1/n1 + 1/n2))Whether the difference in means is larger than sampling noise, assuming equal variances
Cohen's d(m1 - m2) / s_pThe size of the difference in standard deviations, which is what meta-analysis and power calculations consume
Confidence interval(m1 - m2) +/- t s_p sqrt(1/n1 + 1/n2)The range of differences the data is consistent with

Cohen's d is the reason most people arrive at a pooled standard deviation without knowing it. The denominator of d is the pooled value, so a wrong pooling assumption propagates straight into a reported effect size.

When not to pool, and what to do instead

If the two variances are far apart, the Student t test built on a pooled standard deviation reports a confidence it has not earned. The fix is not to pool at all. Welch's t test uses each group's own variance and adjusts the degrees of freedom, and it does not require the equal variance assumption.

The calculator runs both tests every time and prints them side by side, because the honest comparison is the point. If they agree, the pooling assumption did no harm. If they disagree, the assumption is doing the work rather than the data, and Welch is the one to report.

A common rule of thumb is that pooling is safe when the larger sample standard deviation is less than twice the smaller one. That rule is a convenience rather than a theorem, so the calculator prints the actual ratio and lets you judge it. Welch is the safer default in almost every case, and the cost of using it when variances really are equal is very small.

How we know these numbers are right

Every value on this page is computed in your browser from the inputs shown above. Nothing is typed into the copy by hand and nothing is sent to a server.

The routines are the same ones the rest of this site runs on, published under the MIT licence at github.com/theluckystrike/abwex.com. The t distribution tail uses a regularised incomplete beta function evaluated by continued fraction, which is the standard approach and is the same method scipy.stats.ttest_ind documents for the two sample case.

SciPy documents the equal variance switch explicitly. Its equal_var argument defaults to true, which performs the standard independent two sample test that assumes equal population variances, and setting it to false performs Welch's t test, which does not assume equal population variance. That is the same choice this page surfaces, and it is surfaced rather than decided for you.

The Welch degrees of freedom use the Welch Satterthwaite equation, which is what both SciPy and R's t.test use. R's documentation states that if the variance equality option is true then the pooled variance is used to estimate the variance, and otherwise the Welch approximation to the degrees of freedom is used.

What has to be true for these numbers to hold

Common questions

Is the pooled standard deviation just the average of the two?
No, and treating it as one is the most common error. It is the square root of a weighted average of the two variances, not of the two standard deviations, and the weights are degrees of freedom rather than sample sizes. Squaring first, weighting, then taking the root gives a different answer from averaging the two standard deviations directly, and the gap grows as the two spreads diverge.
Why is the denominator n1 plus n2 minus 2?
Each sample spends one degree of freedom estimating its own mean, so two are spent in total. Dividing by the remaining degrees of freedom is what makes the pooled variance an unbiased estimator of the common population variance.
Can I pool more than two groups?
Yes, the same weighting extends to any number of groups, with a denominator of the total sample size minus the number of groups. That quantity is the root mean square error in an analysis of variance. This calculator handles the two group case, which is what a t test and Cohen's d need.
Which test should I report if the two disagree?
Welch. It answers the same question without requiring the equal variance assumption, and when the variances really are equal it gives almost the same answer as the pooled test. If the two disagree, the disagreement is being produced by an assumption rather than by your data.

Read this before you act on the output

Related, false discovery rate calculator for when you are comparing more than one metric at a time, and the t test calculator for the single comparison case.