One-sample t-test calculator with worked example

By Jude Wallis · Published

A one-sample t-test checks whether a population mean differs from a claimed value using t = (x-bar - mu0) / (s / sqrt(n)) with n - 1 degrees of freedom. Enter the sample mean, standard deviation, size, and claimed mean to get t and a p-value.

one-sample t-test (df = 24)

t = 1.8852, p = 0.0716

At alpha = 0.05: fail to reject the null hypothesis. Interpret in context; for paired data, run this test on the differences.

Steps

  1. 1.SE = s / sqrt(n) = 6.1 / sqrt(25) = 1.22
  2. 2.t = (x-bar - mu0) / SE = (52.3 - 50) / 1.22 = 1.8852
  3. 3.df = n - 1 = 24
  4. 4.p-value (two-sided) = 0.0716

AP Statistics: Unit 4 (topics 4.4 Setting Up a Test for a Population Mean or Population Mean Difference, 4.5 Carrying Out a Test for a Population Mean or Population Mean Difference). This calculator supports Unit 4 topics 4.4 and 4.5 of the Fall 2026 AP Statistics course, inference for a population mean or population mean difference.

When to use a one-sample t-test

Use a one-sample t-test when you have one quantitative sample and want to know whether its population mean, written μ\mu (the true average for the whole group), differs from a specific claimed value μ0\mu_0 (the number you are testing against). You know the sample but not the population's true spread, so you estimate it from the data. That estimate is what makes this a t-test rather than a z-test.

The sample mean is written xˉ\bar{x} (the average of your data), and the sample standard deviation is ss (how spread out your data is). You also need the sample size nn. If you actually knew the population standard deviation σ\sigma (the true spread of the whole group), you would use a z-test, but that is rare with real data.

Set up your hypotheses

The null hypothesis says the population mean equals the claimed value:

H0:μ=μ0H_0: \mu = \mu_0

The alternative hypothesis takes one of three forms, depending on your question:

  • Ha:μμ0H_a: \mu \neq \mu_0 for a two-sided test (the mean is different)
  • Ha:μ>μ0H_a: \mu > \mu_0 for a one-sided test (the mean is larger)
  • Ha:μ<μ0H_a: \mu < \mu_0 for a one-sided test (the mean is smaller)

Pick the alternative before you look at the data. A two-sided test is the safe default when you have no reason to expect a particular direction. For more on setting these up, see null vs alternative hypothesis.

The one-sample t-test formula

The College Board writes every standardized test statistic as (statistic minus parameter) divided by the standard error of the statistic. For a mean that gives:

t=xˉμ0s/nt = \frac{\bar{x} - \mu_0}{s / \sqrt{n}}

The denominator s/ns / \sqrt{n} is the standard error (SE), the estimated standard deviation of the sample mean. The degrees of freedom, written dfdf (the value that sets the shape of the t-distribution), equal

df=n1df = n - 1

A larger t|t| means your sample mean sits farther from μ0\mu_0 in standard-error units, which produces a smaller p-value.

Conditions to check first

Three conditions support a one-sample t-test:

  • Random: the data come from a random sample or a randomized experiment.
  • Independent: observations are independent. When you sample without replacement, the population should be at least 10 times the sample size.
  • Normal: the sampling distribution of xˉ\bar{x} is approximately normal. This holds if the population is roughly normal, if n30n \geq 30 by the central limit theorem, or if a plot of a smaller sample shows no strong skew or outliers.

State these conditions in any free-response answer before you compute the statistic.

How to use this one sample t test calculator

Enter four numbers into the one sample t test calculator: the sample mean xˉ\bar{x}, the sample standard deviation ss, the sample size nn, and the claimed mean μ0\mu_0. Then choose your alternative hypothesis: two-sided, greater than, or less than.

The tool returns the standard error, the t statistic, the degrees of freedom, and the p-value. If you have raw data instead of summary numbers, find xˉ\bar{x} and ss first with the standard deviation calculator, then bring those values here.

Read the result and write a conclusion

Compare the p-value to your significance level α\alpha (alpha, the threshold you set in advance, often 0.05). If the p-value is less than or equal to α\alpha, reject H0H_0. If it is greater than α\alpha, fail to reject H0H_0.

Here is a conclusion template you can reuse at α=0.05\alpha = 0.05: "Because the p-value of [value] is [less than / greater than] 0.05, we [reject / fail to reject] H0H_0. We [do / do not] have convincing evidence that the population mean [differs from / is greater than / is less than] [μ0\mu_0 stated in context]."

If you want the interpretation in more depth, read what does a p-value mean.

Paired data: run the test on the differences

A paired design gives two measurements on each subject, such as a before value and an after value. Do not run two separate tests. Instead, subtract to get one difference for each subject, then run a one-sample t-test on that single column of differences.

The hypotheses use the mean difference μd\mu_d (the true average of the paired differences), usually with H0:μd=0H_0: \mu_d = 0. The AP course treats this as the same procedure, a test for a population mean difference, so you enter the mean, standard deviation, and count of the differences into the same calculator.

Testing a claimed mean of 50

A random sample of 25 measurements has a mean of 52.3 and a standard deviation of 6.1. Test whether the population mean differs from 50 at a significance level of 0.05.

  1. State the hypotheses: H0:μ=50H_0: \mu = 50 and Ha:μ50H_a: \mu \neq 50 (two-sided).

  2. Record the values: xˉ=52.3\bar{x} = 52.3, s=6.1s = 6.1, n=25n = 25, and μ0=50\mu_0 = 50.

  3. Check conditions: the sample is random, and because n=25n = 25 is below 30, assume the population is approximately normal or that the data show no strong skew or outliers.

  4. Standard error: s/n=6.1/25=6.1/5=1.22s / \sqrt{n} = 6.1 / \sqrt{25} = 6.1 / 5 = 1.22.

  5. Test statistic: t=52.3501.22=2.31.22=1.885t = \frac{52.3 - 50}{1.22} = \frac{2.3}{1.22} = 1.885.

  6. Degrees of freedom: df=n1=251=24df = n - 1 = 25 - 1 = 24.

  7. P-value: for t=1.885t = 1.885 with df=24df = 24, the two-sided p-value is about 0.0716.

  8. Compare: 0.0716 is greater than α=0.05\alpha = 0.05.

Fail to reject H0H_0. With a two-sided p-value of about 0.0716 at α=0.05\alpha = 0.05, there is not convincing evidence that the population mean differs from 50.

Frequently asked questions

When should I use a t-test instead of a z-test?

Use a t-test when you estimate the standard deviation from your sample, which is almost always the case with real data. Use a z-test only when the population standard deviation is already known. The t-test vs z-test guide covers the difference.

What degrees of freedom does a one-sample t-test use?

The degrees of freedom equal n1n - 1, where nn is your sample size. For a sample of 25, that is 24. The degrees of freedom set which t-distribution you use to find the p-value.

Can I use this calculator for paired data?

Yes. First subtract the two measurements for each subject to get a single column of differences, then enter the mean, standard deviation, and count of those differences. The test then checks whether the mean difference equals zero.

Does a large p-value mean the null hypothesis is true?

No. Failing to reject H0H_0 means you did not find convincing evidence against it, not that it is true. You simply lack the evidence to rule it out at your chosen significance level.