Df Calculator t Test: Degrees of Freedom Explained
- Pooled df (equal variance)
- Result
- Sample 1 size
- 10
- You entered
- Sample 2 size
- 12
- You entered
This calculator works out the degrees of freedom (df) for a two-sample t-test, which is the number of independent values that are free to vary when estimating the test statistic. You enter the sample sizes and, for the unequal-variance (Welch) version, the sample standard deviations, and you get back the df value you need to look up in a t-distribution table. The result tells you which row of the table to use, or which value to enter into a p-value calculator, so you can decide whether the difference between two group means is statistically significant.
Formula
The degrees of freedom for a two-sample t-test depends on whether you assume the two populations have equal variances. The simpler, pooled formula assumes equal variances and is:
df = n� + n₂ − 2
where n� and n₂ are the sample sizes of the two groups. For example, with 10 and 12 observations, df = 10 + 12 − 2 = 20.
The Welch (unequal variance) formula is more complex. It uses the sample standard deviations (s� and s₂) and sample sizes:
df = ( (s�²/n�) + (s₂²/n₂) )² / ( (s�²/n�)²/(n�−1) + (s₂²/n₂)²/(n₂−1) )
This is called the Welch–Satterthwaite equation. It produces a fractional df (like 19.37), and you round down to the nearest integer when using a printed t-table. The calculator above shows both values, so you can compare.
Worked Example
Using the default values from the calculator: n� = 10, n₂ = 12, s� = 5, s₂ = 6.
First compute the variance of each mean (standard error squared):
- s�²/n� = 25/10 = 2.5
- s₂²/n₂ = 36/12 = 3.0
Sum: 2.5 + 3.0 = 5.5. Square it: 5.5² = 30.25.
Now compute the denominator:
- (2.5)²/(10−1) = 6.25/9 = 0.6944
- (3.0)²/(12−1) = 9/11 = 0.8182
- Sum = 0.6944 + 0.8182 = 1.5126
Divide: 30.25 / 1.5126 = 20.00 (rounded to two decimals). The pooled df is 10 + 12 − 2 = 20. In this case they match because the standard deviations and sample sizes are proportional, but they often differ.
When to Use Which df
Choosing the wrong df can change your p-value and your conclusion. Here is the practical guidance:
- Use pooled df (n� + n₂ − 2) when you are confident the population variances are roughly equal. This is the classic Student’s t-test taught in intro stats. It has slightly more power when the assumption holds.
- Use Welch df when the sample standard deviations differ by more than a factor of about 1.5, or when you are not sure. Welch’s t-test does not assume equal variances, and it is the default in most modern statistical software (R, Python, SPSS) because it is safer.
- For paired t-tests (same subjects measured twice), df = number of pairs − 1. That is a different formula entirely, not covered by this calculator.
If you are doing a one-sample t-test (comparing a mean to a known value), df = n − 1, where n is the sample size. That is also not what this calculator computes.
Reading the Result
The df value itself is not the p-value. It is the parameter that defines the shape of the t-distribution. A larger df makes the t-distribution closer to a normal distribution. Here is how to use the df you get:
- Calculate your t-statistic from your data (not shown here).
- Find the row in a t-table that matches your df (round down if fractional).
- Compare your t-statistic to the critical value for your chosen alpha level (usually 0.05).
- Or enter your t-statistic and df into a p-value calculator to get the exact p-value.
For example, with df = 20 and alpha = 0.05 (two-tailed), the critical t-value is about 2.086. If your t-statistic is larger than that, the result is significant at the 5% level.
Common Mistakes
Several errors trip up students and analysts:
- Using n instead of n−1 in the pooled formula. The −2 comes from estimating two means, so you lose two degrees of freedom, not zero.
- Rounding the Welch df up to the nearest integer. Always round down to be conservative. If your df is 19.37, use 19 in the table.
- Using the pooled df when variances are very different. This can inflate the Type I error rate (false positives). Welch is safer.
- Forgetting that df must be positive. With sample sizes of 1, the formula breaks down because you cannot estimate a variance from one observation. The calculator enforces a minimum of 2 per group.
- Confusing df with sample size. They are related but not the same. df is always smaller than the total sample size.
Limits of the Formula
The Welch formula is an approximation, not an exact value. It works well when both samples are reasonably large (say, over 5) and the data are not extremely skewed. For very small samples or heavily skewed distributions, the approximation may be off, and a permutation test or bootstrap might be more reliable. Also, the formula assumes the two samples are independent. If your data are paired or clustered, these df formulas do not apply.
Another limitation: the df is only part of the t-test. You still need the t-statistic, which depends on the means and standard deviations. The calculator above gives you the df, but you must compute the t-statistic separately (many online t-test calculators do both).
Frequently Asked Questions
What does df mean in a t-test?
Degrees of freedom (df) represent the number of independent pieces of information available to estimate a parameter. In a two-sample t-test, you lose one df for each mean you estimate, so the pooled df is n� + n₂ − 2. It determines the shape of the t-distribution you use to find the p-value.
Why is Welch df not a whole number?
Because the Welch–Satterthwaite equation combines sample variances and sizes in a ratio, the result is often fractional, like 19.37. This is normal. When using a printed t-table, round down to the nearest integer. Statistical software uses the fractional value directly for p-value calculations.
Can df be zero or negative?
No, not in a valid t-test. The pooled df is n� + n₂ − 2, which is at least 2 if each sample has at least 2 observations. The Welch df can be very small (even below 1) if one sample has size 2 and the other is large, but it will still be positive. A df of 0 or negative means your sample sizes are too small to estimate the variances.
What is the difference between pooled and unpooled df?
Pooled df assumes equal variances and is simply n� + n₂ − 2. Unpooled (Welch) df does not assume equal variances and is computed with the complex formula above. The pooled test has more df (and thus more power) when the assumption holds, but Welch is safer when variances differ.
Which df should I report in my paper?
Report the df that matches the test you actually ran. If you used Welch’s t-test, report the Welch df. If you used Student’s t-test, report the pooled df. Most modern journals and software default to Welch, so check your analysis output. In a results section, you might write: “t(20) = 2.45, p = 0.023� where 20 is the df.
Related
Formula used
in n1 | Sample 1 size | - | 10 | 2 in n2 | Sample 2 size | - | 12 | 2 in s1 | Sample 1 SD | - | 5 | 0 in s2 | Sample 2 SD | - | 6 | 0 out df_welch | Welch df | - | (((s1^2/n1)+(s2^2/n2))^2) / (((s1^2/n1)^2/(n1-1))+((s2^2/n2)^2/(n2-1))) | 2 out df_pooled | Pooled df (equal variance) | - | n1 + n2 - 2 | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.