Why is df a decimal on a two-sample t-test?

By Jude Wallis · Published

Nothing is wrong with what you typed. A two-sample t-test gets its degrees of freedom from the Welch-Satterthwaite formula, which mixes both groups' variances and sample sizes and almost never lands on a whole number. Report the technology value. By hand, use the smaller of n1 - 1 and n2 - 1.

AP Statistics: Unit 4 (topics 4.9 Setting Up a Test for the Difference Between Two Population Means, 4.10 Carrying Out a Test for the Difference Between Two Population Means). Two-sample t procedures sit in Unit 4 (topics 4.9 and 4.10) of the Fall 2026 AP Statistics course, where the degrees of freedom fall between the smaller of n1 - 1 and n2 - 1 and the value n1 + n2 - 2 and you find them with technology.

The short answer: a decimal df is correct

You did not mistype a sample size. A two-sample t-test computes its degrees of freedom with the Welch-Satterthwaite formula, and that formula almost never returns a whole number. A calculator reporting df=17.34df = 17.34 is doing exactly what it was built to do.

The decimal feels wrong because every other df in this course is a count of something. A one-sample t-test uses df=n1df = n - 1. A paired t-test uses df=n1df = n - 1 on the column of differences. A chi-square test counts categories: k1k - 1 for goodness of fit, (r1)(c1)(r-1)(c-1) for a two-way table. All whole numbers. The two-sample t-test is the one place in AP Statistics where df stops being a count and becomes a setting that picks the shape of a curve, and shape settings have no reason to be integers.

Two facts cover the practical question. Report the df your technology gives you, decimal and all. If you are working by hand from a t-table, use the conservative df: the smaller of n11n_1 - 1 and n21n_2 - 1.

Where the decimal comes from

The standard error for a difference of two means keeps the groups apart:

SE=s12n1+s22n2SE = \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}

Each group hands over its own estimated variance, s12s_1^2 and s22s_2^2, computed from its own sample. That is the whole source of the decimal. The t curve you need depends on how precisely SESE has been estimated, and here it is estimated from two samples that can differ in size and in spread. One integer cannot describe that mixture.

The Welch-Satterthwaite formula finds the t curve that matches the mixture:

df=(s12n1+s22n2)21n11(s12n1)2+1n21(s22n2)2df = \frac{\left(\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}\right)^2}{\frac{1}{n_1 - 1}\left(\frac{s_1^2}{n_1}\right)^2 + \frac{1}{n_2 - 1}\left(\frac{s_2^2}{n_2}\right)^2}

Read it as a weighted average in disguise. When one group's s2n\frac{s^2}{n} term dominates the standard error, the df slides down toward that group's n1n - 1, because that group's uncertainty is running the show. When the two terms contribute evenly, the df climbs toward the combined total. Nothing in that arithmetic is forced to land on an integer.

A t curve with df=17.34df = 17.34 is a real curve, not an approximation to a nearby integer one. The t density is defined for any positive df through the gamma function, which extends factorials to non-integer inputs, so software computes a p-value from it directly. You are not asked to evaluate the Welch formula by hand on the AP exam. You are asked to recognize the number and use it.

The df has to land between two numbers, so use that as a typo check

The Welch df always sits inside a fixed window:

min(n11,n21)dfn1+n22\min(n_1 - 1, n_2 - 1) \le df \le n_1 + n_2 - 2

That window is the fastest way to confirm you entered the data correctly. Suppose n1=9n_1 = 9 and n2=22n_2 = 22. The floor is 91=89 - 1 = 8 and the ceiling is 9+222=299 + 22 - 2 = 29. A reported df=17.34df = 17.34 falls inside, so the entry is fine. A reported df=31df = 31 or df=3df = 3 would mean a sample size or a standard deviation really did get typed wrong.

The two ends also explain why some examples never show a decimal at all. The df reaches its ceiling of n1+n22n_1 + n_2 - 2 when the groups contribute in proportion, which happens when s12n1(n11)=s22n2(n21)\frac{s_1^2}{n_1(n_1-1)} = \frac{s_2^2}{n_2(n_2-1)}. Equal sample sizes with equal sample standard deviations is the familiar case, so a textbook example built from tidy matched numbers can hand you a whole-number df and hide the issue completely. At the other end, the df drops to near the smaller n1n - 1 when one small group carries most of the standard error.

Why your calculator and the board work disagree

There are three df values in circulation for two independent means, and your teacher was almost certainly using a different one from your calculator.

Routedf it givesWhere you meet it
Welch, from technologya decimal, such as 17.34TI-84 2-SampTTest with Pooled: No, and most software
Conservative, by handsmaller of n11n_1 - 1 and n21n_2 - 1board work and homework done from a t-table
Pooledn1+n22n_1 + n_2 - 2TI-84 with Pooled: Yes, and older textbooks

The pooled route assumes the two populations have the same standard deviation, then combines both samples into one estimate of it. That assumption buys back a whole-number df, and it is why n1+n22n_1 + n_2 - 2 shows up so often. The AP formula sheet lists only the unpooled standard error for means, the s12/n1+s22/n2\sqrt{s_1^2/n_1 + s_2^2/n_2} version above, so on this exam you choose Pooled: No and live with the decimal. That setting gets its own walkthrough in pooled or not on a two-sample t-test.

The conservative route is the honest by-hand substitute. Using the smaller n1n - 1 gives a t curve with tails at least as heavy as the true one, so the p-value comes out at least as large as the exact value. It can never make your evidence look stronger than it is. That is the trade: a bit of power lost, no risk of overstating the result.

What to report, and what not to round

Report the df you actually used, right next to your test statistic and p-value. That single habit removes the confusion for whoever reads your work, since t=2.565t = 2.565 means different things at df=8df = 8 and df=29df = 29.

Do not round the df before finding the p-value if your technology can use the exact value. If a table forces you onto a whole-number row, round down, never up. Rounding down keeps the tails a little heavier and the p-value a little larger. Rounding up thins the tails and shrinks the p-value below the truth, which is the one direction you cannot afford.

Here is what the choice actually costs. Every row holds the same t=2.565t = 2.565 from the worked example below, so the table isolates what the df alone does:

df usedTwo-sided p-value
8 (conservative)0.033
17 (rounded down)0.020
17.34 (Welch)0.020
18 (rounded up)0.019
29 (the ceiling, n1+n22n_1 + n_2 - 2)0.016

Rounding down costs almost nothing, and the conservative df is noticeably more cautious. A bigger df thins the tails and shrinks the p-value, which is why the bottom row is the smallest number in the column.

That bottom row is not a pooled test. Pooling changes the standard error as well as the df, so it never just slides you down this table. Run the same battery data pooled and you get sp=3.369s_p = 3.369, SE=1.333SE = 1.333, t=2.400t = 2.400, and p=0.023p = 0.023 at df=29df = 29, which is larger than the Welch 0.020, not smaller. Pooling is not reliably generous and not reliably safe either: it assumes the two populations share one standard deviation, and when that assumption fails the p-value can move either way. It comes out too small when the smaller sample is the more variable one. That is why the AP formula sheet lists only the unpooled standard error. You can check any of these against the two-sample t-test calculator, and see how the output is laid out in reading calculator output.

Mistakes to avoid

  • Do not round a decimal df up to reach a table row. Round down, or let technology use the exact value.
  • Do not pair the unpooled standard error with df=n1+n22df = n_1 + n_2 - 2. Those belong to different procedures, and the mismatch reports a p-value that is too small.
  • Do not read the df as a count of data values. With n1=9n_1 = 9 and n2=22n_2 = 22 you have 31 observations and a df of 17.34, and both are correct at once.
  • Do not run a two-sample test on paired data. Before-and-after measurements on the same subjects collapse to one column of differences with df=n1df = n - 1, a whole number again. See paired vs two-sample t-test.
  • Do not report the calculator's df and then look up a critical value at some other df. Keep the p-value, the interval, and the stated df on the same curve.
  • Do not panic at a df of 17.34 and switch to a z-test. The reason for using t has not changed: σ\sigma is unknown for both groups. See t-test vs z-test.

Where df = 17.34 comes from, digit by digit

Independent random samples of AA batteries are tested for lifetime in hours. Brand A: n1=9n_1 = 9, xˉ1=41.2\bar{x}_1 = 41.2, s1=3.0s_1 = 3.0. Brand B: n2=22n_2 = 22, xˉ2=38.0\bar{x}_2 = 38.0, s2=3.5s_2 = 3.5. Neither sample shows strong skewness or outliers. Find the standard error, the Welch degrees of freedom, the t statistic, and the two-sided p-value for H0:μ1μ2=0H_0: \mu_1 - \mu_2 = 0.

  1. Conditions: two independent random samples, each well under 10% of its brand's production, and neither sample shows strong skewness or outliers, so two-sample t procedures apply.

  2. Group A term: s12n1=3.029=99=1\frac{s_1^2}{n_1} = \frac{3.0^2}{9} = \frac{9}{9} = 1.

  3. Group B term: s22n2=3.5222=12.2522=0.556818\frac{s_2^2}{n_2} = \frac{3.5^2}{22} = \frac{12.25}{22} = 0.556818.

  4. Standard error: SE=1+0.556818=1.556818=1.2477SE = \sqrt{1 + 0.556818} = \sqrt{1.556818} = 1.2477 hours.

  5. Welch numerator: square the sum from the last step, (1.556818)2=2.423683(1.556818)^2 = 2.423683.

  6. Welch denominator, first piece: 1n11(s12n1)2=128=0.125\frac{1}{n_1 - 1}\left(\frac{s_1^2}{n_1}\right)^2 = \frac{1^2}{8} = 0.125.

  7. Welch denominator, second piece: 1n21(s22n2)2=0.556818221=0.31004621=0.014764\frac{1}{n_2 - 1}\left(\frac{s_2^2}{n_2}\right)^2 = \frac{0.556818^2}{21} = \frac{0.310046}{21} = 0.014764.

  8. Add the two pieces: 0.125+0.014764=0.1397640.125 + 0.014764 = 0.139764.

  9. Degrees of freedom: df=2.4236830.139764=17.34df = \frac{2.423683}{0.139764} = 17.34.

  10. Check the window: the smaller of n11=8n_1 - 1 = 8 and n21=21n_2 - 1 = 21 is 8, and n1+n22=29n_1 + n_2 - 2 = 29. Since 817.34298 \le 17.34 \le 29, the value is legitimate and the data were entered correctly.

  11. Test statistic: t=(41.238.0)01.2477=3.21.2477=2.565t = \frac{(41.2 - 38.0) - 0}{1.2477} = \frac{3.2}{1.2477} = 2.565.

  12. Two-sided p-value from technology at df=17.34df = 17.34: p=0.020p = 0.020.

SE=1.2477SE = 1.2477 hours, df=17.34df = 17.34, t=2.565t = 2.565, and p=0.020p = 0.020. The decimal is the Welch value, and it passes the 8df298 \le df \le 29 check. At the 0.05 level you reject H0H_0: there is convincing evidence that the mean lifetimes of the two battery brands differ.

The same test by hand, with the conservative df

Take the battery data above, with t=2.565t = 2.565 and SE=1.2477SE = 1.2477 hours, and suppose no calculator is available. Test at α=0.05\alpha = 0.05 using a t-table, then build a 95% confidence interval for μ1μ2\mu_1 - \mu_2.

  1. Conditions carry over from the example above: independent random samples, each under 10% of its brand's production, no strong skewness or outliers.

  2. Conservative df: the smaller of n11=8n_1 - 1 = 8 and n21=21n_2 - 1 = 21, so use df=8df = 8.

  3. Read row 8 of the t-table. The 95% column (total tail area 0.05) gives t=2.306t^* = 2.306, and the 98% column (total tail area 0.02) gives t=2.896t^* = 2.896.

  4. Place your statistic: t=2.565t = 2.565 sits between 2.306 and 2.896, so the two-sided p-value is between 0.02 and 0.05.

  5. Decide: pp is below α=0.05\alpha = 0.05 because t=2.565t = 2.565 exceeds the 0.05 critical value 2.306, so reject H0H_0. Technology at df=8df = 8 would report p=0.033p = 0.033.

  6. Conservative interval: 3.2±2.306×1.2477=3.2±2.8773.2 \pm 2.306 \times 1.2477 = 3.2 \pm 2.877, giving (0.32,6.08)(0.32, 6.08) hours.

  7. Welch interval for comparison, using df=17.34df = 17.34 and t=2.107t^* = 2.107: 3.2±2.107×1.2477=3.2±2.6293.2 \pm 2.107 \times 1.2477 = 3.2 \pm 2.629, giving (0.57,5.83)(0.57, 5.83) hours.

  8. Compare the two routes: the conservative df gives the larger p-value (0.033 against 0.020) and the wider interval, every time.

With df=8df = 8 the t-table gives 0.02<p<0.050.02 < p < 0.05, so you reject H0H_0 at the 0.05 level, and the 95% interval is (0.32,6.08)(0.32, 6.08) hours. The Welch route gives p=0.020p = 0.020 and (0.57,5.83)(0.57, 5.83). Same conclusion, with the by-hand version deliberately more cautious.

Frequently asked questions

Is a decimal df a sign that I entered something wrong?

No. The Welch-Satterthwaite formula returns a non-integer for almost every data set. Check it against the window instead: the df must fall between the smaller of n11n_1 - 1 and n21n_2 - 1 and the value n1+n22n_1 + n_2 - 2. If it does, your entry is fine.

Should I round 17.34 to 17 or to 18?

Neither, if your technology can use 17.34 directly. If a table forces a whole number, round down to 17. Rounding down keeps the tails heavier and the p-value slightly larger. Rounding up to 18 shrinks the p-value below its true value, in this example to 0.019 instead of 0.020.

Why isn't the df just $n_1 + n_2 - 2$?

That is the pooled df, and it requires assuming both populations have the same standard deviation. The AP formula sheet gives only the unpooled standard error, which estimates each group's spread separately, so the matching df is the Welch value. It is never larger than n1+n22n_1 + n_2 - 2.

Which df should I use on the AP exam?

The course expects you to find the df with technology, so use the value your calculator reports and write it down with your test statistic and p-value. If you are working from a table instead, use the conservative df, the smaller of n11n_1 - 1 and n21n_2 - 1, and state that you did.