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.SE = s / sqrt(n) = 6.1 / sqrt(25) = 1.22
- 2.t = (x-bar - mu0) / SE = (52.3 - 50) / 1.22 = 1.8852
- 3.df = n - 1 = 24
- 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 (the true average for the whole group), differs from a specific claimed value (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 (the average of your data), and the sample standard deviation is (how spread out your data is). You also need the sample size . If you actually knew the population standard deviation (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:
The alternative hypothesis takes one of three forms, depending on your question:
- for a two-sided test (the mean is different)
- for a one-sided test (the mean is larger)
- 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:
The denominator is the standard error (SE), the estimated standard deviation of the sample mean. The degrees of freedom, written (the value that sets the shape of the t-distribution), equal
A larger means your sample mean sits farther from 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 is approximately normal. This holds if the population is roughly normal, if 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 , the sample standard deviation , the sample size , and the claimed mean . 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 and 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, the threshold you set in advance, often 0.05). If the p-value is less than or equal to , reject . If it is greater than , fail to reject .
Here is a conclusion template you can reuse at : "Because the p-value of [value] is [less than / greater than] 0.05, we [reject / fail to reject] . We [do / do not] have convincing evidence that the population mean [differs from / is greater than / is less than] [ 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 (the true average of the paired differences), usually with . 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.
State the hypotheses: and (two-sided).
Record the values: , , , and .
Check conditions: the sample is random, and because is below 30, assume the population is approximately normal or that the data show no strong skew or outliers.
Standard error: .
Test statistic: .
Degrees of freedom: .
P-value: for with , the two-sided p-value is about 0.0716.
Compare: 0.0716 is greater than .
Fail to reject . With a two-sided p-value of about 0.0716 at , 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 , where 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 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.