Curious Minds

Clear answers to science and history questions

Why Is df a Decimal in a Two-Sample t-Test?

· 5 min read · Science

In a two-sample t-test, the degrees of freedom (df) often come out as a decimal because the standard version of the test—Welch's t-test—does not assume equal variances and uses a fractional formula for df. The more familiar pooled-variance (Student's) t-test always gives an integer df, but statistical software defaults to Welch's method, which produces a decimal df to better approximate the sampling distribution when group variances and sample sizes differ.

Background: What Degrees of Freedom Mean

Degrees of freedom (df) is a concept from estimation and hypothesis testing. In its simplest form, it counts the number of independent pieces of information used to estimate a parameter, minus the number of parameters already estimated. For a one-sample t-test with n observations, df = n − 1 because one parameter (the mean) has been estimated from the data. For a pooled two-sample t-test with groups of sizes n1 and n2, df = n1 + n2 − 2 because two group means are estimated. These are integers because they come from simple counting.

The decimal df arises when the test does not pool variances. Instead of a single variance estimate, the standard error of the difference in means is built from two separate variance estimates, each with its own df. The resulting reference distribution is not exactly a t-distribution, so the df is approximated by a formula that yields a non-integer value.

How the Decimal df Is Calculated

The Welch–Satterthwaite equation gives the df for Welch's t-test. Let s12 and s22 be the sample variances, and n1 and n2 the sample sizes. The formula is:

df = ( s12/n1 + s22/n2 )2 / [ ( s12/n1 )2/(n1 − 1) + ( s22/n2 )2/(n2 − 1) ]

Because the numerator and denominator involve squared terms and ratios of variances and sample sizes, the result is almost never a whole number. For example, with group 1 having variance 4 and n = 10, and group 2 having variance 9 and n = 15, the df works out to roughly 21.3. Software typically reports this value to two decimal places.

The formula is an approximation, not an exact derivation. It matches the first two moments of the Welch statistic to a t-distribution, which is why the df can be fractional. The approximation is very accurate for most practical sample sizes.

Why Software Defaults to Welch's Test

Many statistical packages—including R's t.test() and SPSS's independent-samples t-test—use Welch's t-test by default. The reason is robustness: the pooled-variance t-test assumes equal population variances, and when that assumption is violated and sample sizes are unequal, the pooled test can have inflated Type I error rates (false positives). Welch's test does not assume equal variances and maintains better control of error rates across a wider range of situations.

Because Welch's test is the default, users often see a decimal df without realizing they are running a different variant. The decimal is a signal that the test is using the Welch–Satterthwaite approximation rather than the pooled formula.

When df Stays an Integer

If you choose the pooled-variance (Student's) t-test, the df is always an integer: n1 + n2 − 2. This happens when you explicitly request equal variances in software, or when you compute the test by hand using the pooled standard error. Some older textbooks and courses teach only the pooled version, which can lead to confusion when software reports a decimal.

In practice, the choice between pooled and Welch matters most when group sizes and variances differ substantially. When variances are equal and sample sizes are balanced, the two tests give very similar results, and the df values are close (though Welch's will still be fractional).

Common Misconceptions and Practical Implications

A common misconception is that a decimal df indicates an error or a problem with the data. It does not; it is a normal output of Welch's test. Another misconception is that the decimal df should be rounded to the nearest integer before looking up a critical value. In modern software, the p-value is computed directly from the t-distribution with the fractional df, so rounding is unnecessary and can slightly change the result. If you must use a printed t-table, rounding down to the nearest integer is the conservative approach, but software avoids this issue entirely.

It is also worth noting that the Welch df can be smaller than the pooled df, especially when one group has a much larger variance and a smaller sample size. A smaller df means slightly wider confidence intervals and less power, which is the price of not assuming equal variances. However, the loss is usually modest, and the gain in robustness is generally worth it.

Frequently Asked Questions

Why does my t-test output show df = 23.45?

That decimal df comes from Welch's t-test, which uses the Welch–Satterthwaite approximation to handle unequal variances. It is not an error; it is the default in many software packages.

Can I just round the df to the nearest whole number?

You can, but it is not necessary if your software computes the p-value directly. Rounding down is conservative if you are using a printed table. Rounding to the nearest integer may slightly change the p-value.

When should I use the pooled t-test instead of Welch's?

Use the pooled test only when you have strong evidence that the two population variances are equal—for example, from prior studies or a designed experiment with equal variances. Otherwise, Welch's test is the safer default.

Does a decimal df mean my sample size is wrong?

No. The df formula for Welch's test involves variances and sample sizes in a ratio, so it naturally produces non-integer values. Your sample size is fine.

Is Welch's t-test always better than the pooled t-test?

Welch's test is generally more robust to unequal variances and unequal sample sizes. When variances are truly equal and sample sizes are equal, the pooled test has slightly more power, but the difference is small. Most statisticians recommend Welch's as the default.

Why do some textbooks never mention decimal df?

Many introductory textbooks focus on the pooled-variance t-test because it is simpler to teach and compute by hand. Welch's test, with its fractional df, is often introduced later or left to software.

In this article
  1. Background: What Degrees of Freedom Mean
  2. How the Decimal df Is Calculated
  3. Why Software Defaults to Welch's Test
  4. When df Stays an Integer
  5. Common Misconceptions and Practical Implications
  6. Frequently Asked Questions