One mean against a set value

One-sample t-test calculator

Compare the mean of one sample with a fixed value, such as a target, a specification or a published figure. Enter raw data or the mean, SD and n, set the hypothesized mean, and get t, exact p and the confidence interval for the mean.

  • Raw data or mean, SD and n
  • Confidence interval for the mean
  • Matches NIST's worked example

Sources checked on November 21, 2026. Results computed by the site's engine and tested against R and SciPy.

Input

One-sample t-test against 5

t2611.2620
df194
p (two-sided)< 10−300

At the 5% level, there is evidence of a difference between the mean and 5.

Mean9.2615
95% CI of the mean9.2582 to 9.2647
Cohen's d186.9964
Standard error0.0016

n = 195, SD 0.0228. Critical t: 1.9723.

APA t(194) = 2611.26, p < .001, d = 187.00, 95% CI [9.258, 9.265]

Reproduce this result in R or Python

R

m <- 9.26146; s <- 0.022789; n <- 195; mu0 <- 5
t <- (m - mu0) / (s / sqrt(n))
c(t = t, df = n - 1, p = 2 * pt(-abs(t), n - 1))
m + c(-1, 1) * qt(0.975, n - 1) * s / sqrt(n)

Python (SciPy)

from scipy.stats import t as tdist
m, s, n, mu0 = 9.26146, 0.022789, 195, 5
t = (m - mu0) / (s / n ** 0.5)
print(t, n - 1, 2 * tdist.sf(abs(t), n - 1))
half = tdist.ppf(0.975, n - 1) * s / n ** 0.5
print(m - half, m + half)

What the one-sample test asks

The one-sample t-test asks whether a population mean differs from a value you name in advance, called μ0. A machine is meant to fill bottles with 500 ml; a course claims an average score of 70; a lab compares its readings with a certified reference value. The test uses the sample's own SD, which is why it uses the t distribution rather than the normal.

Worked example: NIST's ZARR13 data

The calculator opens with the example in section 1.3.5.2 of the NIST/SEMATECH e-Handbook, which uses the ZARR13 dataset: 195 measurements with mean 9.26146 and SD 0.022789. NIST uses them to test the hypothesis that the mean equals 5.

From those summaries the calculator gives t = 2611.262 on 194 df and a 95% confidence interval of 9.258241 to 9.264679. NIST prints 9.258242 to 9.264679 and t = 2611.284, because it worked from the unrounded data; the small gaps come from rounding the summaries, not from the method. The critical value t(0.975, 194) = 1.9723 matches NIST's 1.9723. The p-value is far too small to print as a decimal, so the calculator shows it as below 10−300, never as zero.

A second example with raw data

Switch to raw data and the calculator holds all twenty extra-sleep values from Student's 1908 data (both drugs together), the example used by R for a one-sample test. Against μ0 = 0, the mean of 1.54 hours gives t = 3.413, df 19, p = 0.0029, and a 95% interval of 0.5956 to 2.4844. Those match R's printed output. Strictly the twenty values are ten patients measured twice, so they are not independent; R uses them only to demonstrate the function, and so do we.

Formula

t = (x̄ − μ0) / (s / √n),   df = n − 1,   CI = x̄ ± t1−α/2, n−1 × s/√n,   d = (x̄ − μ0) / s

The confidence interval does not depend on μ0. It is the same interval the confidence interval calculator gives, and a two-sided test rejects μ0 exactly when the interval at the matching level leaves it out.

Choosing the hypothesized value

μ0 must come from outside the data: a specification, a legal limit, a long-run average or a published value. Picking it after looking at the sample makes the p-value meaningless. If you want to know which values are consistent with the data rather than test one value, read the confidence interval instead.

When the data are not normal

With small samples the test relies on the data being roughly normal. The result shows skewness and flags values far outside the quartiles. With 30 or more values the mean is usually close enough to normal for the test to work well unless the data are very skewed. For small, skewed samples, a Wilcoxon signed rank test on the differences from μ0 is an option, though it tests the median rather than the mean. More detail is in t-test assumptions.

Reporting the result

Give the mean and SD, then t, df, p and the confidence interval, for example: t(19) = 3.41, p = .003, d = 0.76, 95% CI [0.60, 2.48]. The APA reporting guide covers decimals and wording.

Sources