A test statistic is the single number a hypothesis test produces by dividing how far a sample result falls from the null hypothesis by the standard error of that result. Every hypothesis test boils down to one of these — a t-statistic, a z-statistic, an F-statistic, or a chi-square statistic — and once you have it, you compare it against a critical value from the matching distribution to decide whether the result is surprising enough to reject the null hypothesis. This guide walks through the general formula for a test statistic, how to find degrees of freedom for the tests you will meet most often, how to read a t distribution table, and a fully solved numeric example.

Key takeaways

Point Details
A test statistic standardizes your result It expresses the gap between your sample estimate and the null-hypothesis value in standard-error units, so results from different tests can be judged on the same scale.
Degrees of freedom set how extreme is extreme For a one-sample t-test, df = n − 1; every test subtracts one degree of freedom for each parameter estimated from the data before the statistic is computed.
A t distribution table trades convenience for precision A printed table rounds to a handful of alpha levels and df values; a calculator returns the exact critical value for any combination of the two.
The critical value depends on three choices Significance level, one- or two-tailed direction, and degrees of freedom together set the threshold your test statistic has to clear.
A larger |test statistic| is stronger evidence, not proof Crossing the critical value lets you reject the null hypothesis at your chosen significance level — it does not prove the alternative hypothesis is true.

Quick Checklist: Finding Your Test Statistic and Critical Value

Run through these six steps in order for any hypothesis test, whether it is a one-sample t-test, a chi-square test, or an ANOVA.

Quick checklist: finding your test statistic and critical value

  • Identify the test One sample mean: a t-statistic. Two sample means: a pooled or Welch t-statistic. Categorical counts: a chi-square statistic. Several group means at once: an F-statistic.
  • Apply the matching test statistic formula (observed result − value expected under H0) divided by the standard error of that result.
  • Find degrees of freedom Count the independent data points, then subtract one for each parameter you estimated before computing the statistic.
  • Choose a significance level and tail count α = 0.05 is the default; use a one-tailed test only when the alternative hypothesis names a direction, decided before you see the data.
  • Look up or calculate the critical value Match df and α to a row and column of the t distribution table, or use the calculator below for an exact figure.
  • Compare and decide Reject the null hypothesis if the absolute test statistic meets or exceeds the critical value (two-tailed), or if the signed statistic clears it in the stated direction (one-tailed).

What Is a Test Statistic?

A test statistic is a single standardized number that tells you how far your sample result sits from what the null hypothesis predicts, measured in standard-error units rather than in the original units of the data. The general test statistic formula is:

test statistic = (observed result − value expected under H0) / standard error

A test statistic of 0 means the sample landed exactly on the null hypothesis’s prediction. A test statistic of 2 means the result is two standard errors above that prediction; −2 means two standard errors below. The larger the absolute value, the stronger the evidence against the null hypothesis.

The standard error in the denominator does the real work. It measures how much the sample statistic — a mean, a proportion, a difference between two means — would typically vary from one random sample to the next. Dividing by it converts a raw difference, in whatever units the data were measured (milliliters, test scores, response times), into a universal scale you can compare against a critical value. NIST’s e-Handbook of Statistical Methods on testing a single population mean builds the one-sample case around exactly this ratio: the test statistic is the sample mean minus the hypothesized mean, divided by the standard error of the mean.

Two samples with identical raw differences can produce very different test statistics once that standard error is accounted for. A 3 mL gap between a sample mean and a claimed value is unremarkable if cans vary by 20 mL from one to the next, but the same 3 mL gap is striking if cans normally vary by only 1 mL — the test statistic captures that distinction automatically, where the raw difference alone cannot.

When the population standard deviation σ is unknown — the normal situation in practice — that standard error is estimated from the sample itself, and the formula becomes the one-sample t-statistic:

t = (x̄ − μ₀) / (s / √n)

where x̄ is the sample mean, μ₀ is the hypothesized population mean, s is the sample standard deviation, and n is the sample size. The result follows a t-distribution with n − 1 degrees of freedom, not a standard normal distribution, because s is itself estimated with error. When σ is known from an outside, trusted source, the same logic produces a z-statistic instead: z = (x̄ − μ₀) / (σ / √n), compared against the z-score distribution rather than the t.

Calculate a Critical t-Value Instantly

Enter degrees of freedom, a confidence level, and one- or two-tailed below to get the exact critical t-value — no interpolating between rows of a printed t distribution table.

Calculator

T Table Calculator

Enter values and compute the result.

For a larger version with the same inputs, open the standalone t-table calculator. If you already have a test statistic and need the corresponding probability instead of a threshold, use the p-value calculator.

What Is a Degree of Freedom in Statistics?

A degree of freedom (abbreviated df, occasionally written d.f.) is one independent piece of information available for estimating something from your data. In a sample of n values, all n observations are free to vary. The moment you use that sample to estimate a parameter — a mean, say — one piece of information is “used up,” leaving one fewer degree of freedom for whatever you estimate next.

For a one-sample t-test, you estimate the population mean with the sample mean before computing the sample standard deviation, so:

df = n − 1

A sample of 16 observations has df = 15. That number tells the t-distribution how heavy its tails should be: smaller df means heavier tails and larger critical values. As df grows toward infinity, the t-distribution converges on the standard normal, and its critical values converge on the familiar z-scores — 1.645 at 90%, 1.960 at 95%, 2.576 at 99% confidence.

The same n − 1 shows up in the sample standard deviation formula itself, for the same reason. Dividing the sum of squared deviations by n − 1 instead of n (a correction sometimes called Bessel’s correction) compensates for the fact that the sample mean, by construction, is the value that minimizes those squared deviations — using n would systematically underestimate the population variance. NIST’s table of critical values for the Student’s t-distribution labels its last row “Normal Values,” reflecting that convergence. In practice, by roughly 100 degrees of freedom the two distributions are already almost indistinguishable.

Knowing how to find degrees of freedom for other common tests follows the same “data points minus estimated parameters” logic:

How to find degrees of freedom for common hypothesis tests
Test Degrees of freedom Why
One-sample t-test n − 1 One mean estimated from the sample before the standard deviation is computed.
Two-sample t-test (pooled) n₁ + n₂ − 2 Two sample means estimated, one from each group.
Paired t-test number of pairs − 1 The differences become a single sample, so only one mean is estimated.
Chi-square goodness-of-fit k − c k category counts sum to a fixed total; c = (number of distribution parameters estimated from the data) + 1, so c = 1 (and df = k − 1) when no parameters are estimated.
Chi-square test of independence (rows − 1) × (columns − 1) Row and column totals are fixed, constraining the free cells in the table.
One-way ANOVA (F-test) df₁ = k − 1, df₂ = N − k k group means estimated across N total observations.

NIST’s page on comparing two process means and its companion page on paired observations confirm the n₁ + n₂ − 2 and “pairs − 1” rules respectively. For the chi-square goodness-of-fit test, NIST’s handbook page gives df = k − c, where c is the number of estimated parameters plus one — that reduces to the familiar k − 1 only in the common case where no distribution parameter is estimated from the sample, just the category counts themselves. The pattern never changes: start with the number of independent observations, then subtract one for every parameter you had to estimate before you could compute the statistic. The chi-square distribution guide covers how that df value shapes the chi-square curve itself.

A paired t-test is worth a second look because it is easy to miscount. With 20 subjects measured before and after a treatment, it is tempting to write df = 20 + 20 − 2 = 38, as if there were two independent samples. But the paired design collapses each before/after pair into a single difference score, leaving 20 differences rather than 40 independent values — so df = 20 − 1 = 19, not 38. Treating paired data as if it were two independent groups is one of the more common degrees-of-freedom mistakes in practice.

How Do You Read a t Distribution Table?

A t distribution table (also called a table for t distribution, or simply a t table distribution) organizes critical values by two axes: degrees of freedom down the rows, and significance level plus tail count across the columns. Once you have your test statistic and its df, you find the cell where your row and column meet — that cell is the critical value.

Critical values from the t distribution table
df One-tailed α = 0.05 Two-tailed α = 0.10 Two-tailed α = 0.05 Two-tailed α = 0.01
5 2.015 2.015 2.571 4.032
10 1.812 1.812 2.228 3.169
15 1.753 1.753 2.131 2.947
20 1.725 1.725 2.086 2.845
30 1.697 1.697 2.042 2.750
∞ 1.645 1.645 1.960 2.576

A two-tailed test at α = 0.05 splits that 5% evenly between both tails (2.5% each). A one-tailed test at α = 0.05 places the entire 5% in one tail, which is why the one-tailed column always holds a smaller critical value than the two-tailed column at the same α — a smaller rejection threshold is easier to clear, but only in the direction you committed to before collecting data. Notice that the bottom row (∞ df) reproduces the standard normal z-scores exactly, confirming the convergence described above.

Reading down any single column tells its own story: as df falls from 30 to 5, the α = 0.05 two-tailed critical value climbs from 2.042 to 2.571. That increase is the table’s way of penalizing small samples — with fewer data points backing up the estimated standard deviation, the test demands a larger test statistic before it will call a result significant.

How Do You Find a Critical Value for a Hypothesis Test?

Finding a critical value takes three inputs, a lookup, and a comparison, in this order:

  1. Choose the significance level (α). 0.05 (5%) is the conventional default, meaning you accept a 5% chance of rejecting a true null hypothesis (a Type I error). Some fields use the stricter 0.01 or the more lenient 0.10.
  2. Decide one-tailed or two-tailed. Use two-tailed when the alternative hypothesis is H₁: parameter ≠ value — a difference in either direction counts. Use one-tailed only when the alternative specifies a direction (H₁: parameter > value or < value), decided before looking at the data.
  3. Determine degrees of freedom. For a one-sample t-test, df = n − 1; see the table above for other designs.
  4. Look up the table or run the calculator. Find the row matching your df, then the column matching your α and tail count. That cell — or the calculator’s output — is the critical value.
  5. Compare and decide. Reject H₀ if |test statistic| ≥ critical value (two-tailed), or if the signed statistic clears the critical value in the predicted direction (one-tailed). Otherwise, fail to reject.

NIST’s guidance on confidence limits for the mean builds a confidence interval from the same critical value this decision rule uses, just applied to an interval estimate instead of a yes/no test — the null hypothesis guide covers how to state H₀ and H₁ correctly before you get this far.

One-Tailed vs Two-Tailed Tests: Which Critical Value Applies?

The direction you choose changes which critical value you need, and therefore how hard the null hypothesis is to reject:

  • Two-tailed (H₁: μ ≠ μ₀). The rejection region sits in both tails. At α = 0.05 and df = 15, the critical value is 2.131; reject H₀ if |t| ≥ 2.131.
  • One-tailed (H₁: μ > μ₀ or μ < μ₀). The rejection region sits in one tail only. At α = 0.05 and df = 15, the critical value is 1.753; reject H₀ if t ≥ 1.753 (upper-tailed) or t ≤ −1.753 (lower-tailed).

The one-tailed critical value (1.753) is smaller than the two-tailed one (2.131), so it is easier to clear — but only in the predicted direction. If the real effect runs the opposite way, a one-tailed test gives you no way to detect it, no matter how extreme the data are. Decide the tail count from your research question before collecting data; switching to one-tailed after seeing a nearly significant two-tailed result is a form of p-hacking that inflates your real Type I error rate above the stated α.

A one-tailed test fits a question like “does the new process produce cans with more than 355 mL,” where an outcome below 355 mL would never lead to rejecting H₀ regardless of how far below it falls. A two-tailed test fits “does the new process produce cans with a different average than 355 mL,” where deviation in either direction is relevant. Most quality-control and regulatory settings default to two-tailed tests specifically because an unexpected result in the “wrong” direction is still worth catching.

How Does the Test Statistic Formula Change Across Different Tests?

The ratio stays the same — observed minus expected, divided by standard error — but the specific formula for a test statistic depends on what you are comparing.

The test statistic formula by hypothesis test
Test Test statistic formula Distribution used
One-sample t-test t = (x̄ − μ₀) / (s / √n) t, df = n − 1
One-sample z-test z = (x̄ − μ₀) / (σ / √n) Standard normal (z)
Two-sample t-test (pooled) t = (x̄₁ − x̄₂) / (sₚ √(1/n₁ + 1/n₂)) t, df = n₁ + n₂ − 2
Chi-square goodness-of-fit χ² = Σ (O − E)² / E Chi-square, df = k − 1 (no estimated parameters)
One-way ANOVA F = (variance between groups) / (variance within groups) F, df₁ = k − 1, df₂ = N − k

Despite the different symbols, every row answers the same question: how many standard errors away from the null hypothesis does this sample sit? The t-test guide works through the one- and two-sample t formulas with fully solved numbers, the chi-square test guide walks the goodness-of-fit and independence formulas step by step, and t-test vs. z-test covers exactly when to swap s for a known σ.

The two-sample row’s pooled standard deviation, sₚ, is itself a formula worth seeing in full. NIST’s page on comparing two process means builds it from each group’s own sample variance, weighted by its degrees of freedom:

sₚ = √( ((n₁ − 1)s₁² + (n₂ − 1)s₂²) / (n₁ + n₂ − 2) )

where s₁ and s₂ are the two groups’ sample standard deviations and n₁ and n₂ are their sample sizes. That pooled figure then replaces the single s in the one-sample formula’s standard error term.

The pooled two-sample formula above assumes both groups share a common population standard deviation. When that assumption is shaky — one group’s data are noticeably more spread out than the other’s — Welch’s t-test replaces the pooled standard error with one computed from each group’s own variance separately, and its degrees of freedom are no longer a clean integer formula but an approximation based on both sample sizes and variances. Software defaults vary, so check before assuming: R’s t.test() defaults to Welch’s version (var.equal = FALSE), while Python’s scipy.stats.ttest_ind() defaults to the pooled, equal-variance version (equal_var=True) and needs equal_var=False set explicitly to switch to Welch’s.

A Worked Example: Using the Test Statistic Formula Step by Step

Scenario: A beverage company claims its cans hold 355 mL on average. A quality inspector samples 16 cans and measures a mean of 352 mL with a sample standard deviation of 6 mL. At α = 0.05, is there statistically significant evidence the true mean differs from 355 mL?

Test statistic decision process Five steps: state the hypotheses, compute the test statistic, find degrees of freedom, find the critical value, then compare and decide. 1 State thehypotheses H0: mu = 355 mL. H1: muis not 355 mL. 2 Compute the teststatistic t = (352 - 355) / (6 /sqrt(16)) = -2.00. 3 Find degrees offreedom df = 16 - 1 = 15. 4 Find the criticalvalue Two-tailed, alpha =0.05, df = 15: t* =2.131. 5 Compare and decide |-2.00| < 2.131, so failto reject H0.
Figure 1. The five-step path from stated hypotheses to a reject/fail-to-reject decision for the 16-can sample.
  1. State the hypotheses. H₀: μ = 355 mL. H₁: μ ≠ 355 mL (two-tailed).
  2. Compute the test statistic.
    t = (x̄ − μ₀) / (s / √n)
      = (352 − 355) / (6 / √16)
      = −3 / (6 / 4)
      = −3 / 1.5
      = −2.00
    
  3. Find degrees of freedom. df = n − 1 = 16 − 1 = 15.
  4. Find the critical value. At df = 15, two-tailed α = 0.05, the t distribution table gives t* = 2.131.
  5. Compare and decide. |t| = 2.00 is less than t* = 2.131, so the inspector fails to reject the null hypothesis — the sample does not provide strong enough evidence that the cans differ from 355 mL.

If the sample mean had instead been 350.8 mL, the same formula gives t = (350.8 − 355) / 1.5 = −2.80, which exceeds 2.131 in absolute value — that result would reject H₀.

Finding Test Statistics and Critical Values in R, Python, and Excel

Each major tool replaces the printed t distribution table with a direct function call:

R:      qt(0.975, df = 15)        -> 2.131450   # two-tailed critical value, alpha = 0.05
        pt(-2.00, df = 15)        -> 0.03197    # one-tailed p-value for t = -2.00
Python: from scipy.stats import t
        t.ppf(0.975, df=15)       -> 2.131450
        t.cdf(-2.00, df=15)       -> 0.03197
Excel:  =T.INV(0.975, 15)         -> 2.131450

R’s qt() function returns the quantile (critical value) for a given cumulative probability and df, and its companion pt() returns the cumulative probability for a given t and df — the two directions of a t table lookup in one line each. Python’s scipy.stats.t object exposes the same pair through .ppf() and .cdf(). Excel’s T.INV function returns the left-tailed inverse of the t-distribution — passing it 1 − α/2 and your df gives the two-tailed critical value directly, matching the table and the calculator above.

None of these three require you to compute the test statistic by hand first, either. R’s t.test() function and Python’s scipy.stats.ttest_1samp() each take the raw sample plus the hypothesized mean and return the test statistic, degrees of freedom, and p-value together:

R:      t.test(can_volumes, mu = 355)
        # t = -2.00, df = 15, p-value = 0.0639

Python: from scipy.stats import ttest_1samp
        ttest_1samp(can_volumes, popmean=355)
        # TtestResult(statistic=-2.00, pvalue=0.0639, df=15)

Excel’s T.TEST function takes two ranges of raw data rather than a single sample against a hypothesized mean, so it is built for comparing two groups (paired or independent) rather than the one-sample case above — for a one-sample test in Excel, compute the test statistic with the formula directly, then pass it to T.DIST.2T or look it up against T.INV as shown.

Common Mistakes When Working With Test Statistics

  • Using the wrong denominator. The formula uses s / √n, the standard error of the mean, not s alone. Dividing by s makes the denominator too large and the test statistic too small, under-rejecting false null hypotheses. Fix it by writing out the standard error as its own line before dividing, rather than dividing in a single mental step.
  • Ignoring the sign in a two-tailed test. Compare the absolute value of the test statistic against the critical value — a test statistic of −2.5 is exactly as extreme as +2.5. Fix it by taking the absolute value as a deliberate step before the comparison, not by eyeballing which number looks bigger.
  • Using z when σ is unknown, regardless of sample size. The t-distribution with df = n − 1 is the correct choice any time the population standard deviation is estimated from the sample rather than known outright — that includes large samples, not just small ones. The z-distribution’s lighter tails only become a negligible difference as n grows; they do not become “correct” at n = 30. Fix it by checking whether σ is truly known from an external source, not just assumed, before reaching for a z-table.
  • Misreading the t distribution table columns. A two-tailed test at α = 0.05 uses the same column as a one-tailed test at α = 0.025. Confirm which column you are in before recording the critical value, since the two labeling conventions sit side by side in most printed tables.
  • Miscounting degrees of freedom on a paired or two-sample design. Treating paired before/after data as two independent groups inflates df and understates how uncertain the estimate really is. Fix it by asking whether each row of data represents one subject or two before choosing a df formula.
  • Treating “fail to reject” as “proven true.” A test statistic that falls short of the critical value means the data are consistent with the null hypothesis, not that the null hypothesis is confirmed. An underpowered sample size is a common reason for a non-significant result even when a real effect exists, so fix it by reporting the result as “no significant difference detected,” not “no difference exists.”

Statohub’s Take on the Test Statistic

Statohub’s position is that the test statistic formula is worth memorizing in its general form — (observed − expected) / standard error — rather than as a list of unrelated symbols for each test. Once that ratio clicks, the t-statistic, z-statistic, and chi-square statistic stop looking like separate topics and start looking like the same idea applied to different data. Degrees of freedom deserve the same treatment: learn the “data points minus estimated parameters” rule once, and every test’s df formula follows from it rather than needing separate memorization. A printed t distribution table is worth working through by hand once, for the same reason a times table is worth memorizing once — it builds an intuition for how critical values tighten as sample size grows that an instant calculator answer does not teach on its own.

Put the Test Statistic to Work With Statohub’s Tools

The calculator above returns an exact critical t-value for any degrees of freedom, confidence level, and tail count, replacing the row-and-column hunting a printed t distribution table requires — open the standalone t-table calculator for a larger version. Once you have a test statistic in hand, the t-test calculator runs the one-sample case directly from a sample mean, hypothesized mean, standard deviation, and n, and the p-value calculator converts any t or z statistic into its p-value. The Inferential Statistics hub connects this page to the surrounding tests — hypothesis setup, p-values, and the chi-square family — and Statohub’s full calculators hub lists every tool for checking your own numbers.

Sources

Sources

  1. NIST/SEMATECH e-Handbook — 7.2.2. Are the Data Consistent With the Assumed Process Mean? NIST
  2. NIST/SEMATECH e-Handbook — 7.3.1. Do Two Processes Have the Same Mean? NIST
  3. NIST/SEMATECH e-Handbook — 7.3.1.1. Analysis of Paired Observations NIST
  4. NIST/SEMATECH e-Handbook — 1.3.5.15. Chi-Square Goodness-of-Fit Test NIST
  5. NIST/SEMATECH e-Handbook — 1.3.6.7.2. Critical Values of the Student’s-t Distribution NIST
  6. NIST/SEMATECH e-Handbook — 1.3.5.2. Confidence Limits for the Mean NIST
  7. scipy.stats.t — SciPy v1.18.0 Manual SciPy
  8. scipy.stats.ttest_1samp — SciPy v1.18.0 Manual SciPy
  9. scipy.stats.ttest_ind — SciPy v1.18.0 Manual SciPy
  10. R: The Student t Distribution (dt, pt, qt, rt) The R Project
  11. R: Student’s t-Test (t.test) The R Project
  12. T.INV function Microsoft Support
  13. T.TEST function Microsoft Support

FAQ

Frequently asked questions

What Is a Degree of Freedom (df) in Statistics?
A degree of freedom — written df or occasionally d.f. — is one independent piece of information free to vary when you estimate a parameter from data. In a sample of n values, all n can vary freely; once you use that sample to estimate the mean, one piece of information is used up, leaving n − 1 degrees of freedom to estimate the variance or run a t-test. Other tests follow the same "observations minus estimated parameters" rule with their own counts.
What Is the Difference Between a Test Statistic and a P-Value?
The test statistic is a number on the scale of its underlying distribution (t, z, F, or chi-square). The p-value converts that number into a probability — the chance of seeing a test statistic at least this extreme if the null hypothesis were true. A smaller p-value means stronger evidence against H0. Comparing |test statistic| to a critical value and comparing the p-value to α always produce the same decision; the p-value calculator above converts between them directly.
Can a Test Statistic Be Negative?
Yes. A t-statistic or z-statistic is negative whenever the sample result falls below the value the null hypothesis predicts. In the worked example above, a sample mean of 352 mL below the claimed 355 mL produced t = −2.00. For a two-tailed test, only the absolute value matters; for a lower-tailed one-tailed test, a large negative value is exactly what triggers rejection.
How Does the Test Statistic Formula Change for a Two-Sample T-Test?
For two independent groups with equal variances, t = (x̄₁ − x̄₂) / (sₚ × √(1/n₁ + 1/n₂)), with df = n₁ + n₂ − 2, where sₚ is the pooled standard deviation: sₚ = √( ((n₁ − 1)s₁² + (n₂ − 1)s₂²) / (n₁ + n₂ − 2) ), per NIST’s page on comparing two process means. The logic matches the one-sample case: divide the observed difference by its standard error, then compare against the t distribution table. The t-test calculator runs this formula directly from your two groups’ summary statistics.
How Do You Find Degrees of Freedom for a Chi-Square Test?
For a chi-square goodness-of-fit test comparing observed counts across k categories to expected counts, df = k − 1 in the common case where only the category counts themselves are used, since those counts must sum to a fixed total; subtract one more degree of freedom for each additional distribution parameter estimated from the sample. For a chi-square test of independence on a contingency table, df = (rows − 1) × (columns − 1), since the row and column totals constrain how many cells can vary freely. The chi-square test guide works both formulas through fully solved examples.
Why Does the T Distribution Table Converge to the Z-Table as Degrees of Freedom Increase?
The t-distribution has heavier tails than the standard normal because it accounts for the extra uncertainty of estimating the standard deviation from a sample instead of knowing it outright. As degrees of freedom grow, that estimate becomes more reliable, the extra uncertainty shrinks, and the t-distribution’s shape approaches the standard normal’s. By around df = 100, a t table’s critical values and a z-table’s critical values are nearly identical, which is why the bottom "infinity" row of most t tables matches the familiar z-scores of 1.645, 1.960, and 2.576.