One-Sample T-Test Calculator

A one-sample t-test asks whether the mean of your sample is far enough from a reference value that chance alone is an unconvincing explanation. Enter the sample mean, the sample standard deviation, the sample size and the hypothesised mean, and this calculator returns the t statistic, the degrees of freedom, an exact p-value from the Student t distribution, the critical value at your chosen alpha, the reject-or-not decision, and a confidence interval for the difference. It handles two-tailed and both one-tailed alternatives.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Sample mean (x̄)The average of your observations.520
Sample standard deviation (s)Computed with n − 1 in the denominator. Not the standard error.50
Sample size (n)The number of independent observations behind the mean.25
Hypothesised mean (μ₀)The reference value under the null hypothesis: a specification, a historical average, a claim.500
Alternative hypothesisChoose a one-tailed alternative only if you fixed the direction before collecting the data.μ ≠ μ₀ (two-tailed)
Significance level (α)The false-positive rate you are willing to accept. It also sets the confidence interval at 1 − α.0.05

It returns

  • t statistic — How many standard errors your sample mean sits from the hypothesised mean.
  • p-value
  • Decision at your alpha
  • Critical t
  • Degrees of freedom
  • Observed difference (x̄ − μ₀)
  • Lower limit for the difference
  • Upper limit for the difference

The formula

t=x¯μ0s/n
CI=(x¯μ0)±tα/2sn
d=x¯μ0s

In plain text: t = (x̄ − μ₀) / (s / √n), df = n − 1

  • tTest statistic, in standard errors
  • Sample mean
  • μ₀Hypothesised population mean under H₀
  • sSample standard deviation (divisor n − 1)
  • nSample size (count)

The p-value is the tail area of Student's t with n − 1 degrees of freedom beyond the observed statistic — doubled for a two-tailed alternative.

Updated Category Hypothesis Tests & Statistical Power Verified against published test cases Reading time 10 min

What a one-sample t-test decides

You have one group of measurements and one reference number. A machine is supposed to fill bottles to 500 mL; you measure 25 and get 520. A drug's label claims a mean onset of 30 minutes; your trial averages 34. A supplier promises 500 MPa; your sample averages 520. In every case the question is the same: is the gap between your average and the reference bigger than sampling noise can comfortably explain?

The null hypothesis H₀ says the population mean equals μ₀ and the gap you saw is just the luck of which items you happened to measure. The test computes how surprising your data would be if that were true. The answer is the p-value: the probability of seeing a difference at least this extreme, in the direction your alternative allows, when H₀ is exactly true.

Two things about the p-value cause most of the confusion in applied work. It is not the probability that H₀ is true — it is a probability computed assuming H₀ is true. And a large p-value is not evidence that H₀ is true; it means your data cannot distinguish μ₀ from the alternatives, which with a small sample is a statement about your study rather than about the world. That is why this calculator always reports a confidence interval for the difference alongside the p-value: the interval shows exactly which differences remain compatible with your data.

Why the statistic has this shape

The t statistic is a signal-to-noise ratio. The signal is x̄ − μ₀, the raw distance between what you measured and what H₀ claims. The noise is the standard error, s/√n, which is how far a sample mean of that size typically strays from the true mean. Divide one by the other and you get the distance in units of its own typical size, which is what makes t comparable across studies with different units.

Two levers move t. A bigger difference moves it directly and proportionally. A bigger sample moves it as √n: quadruple the observations and the same raw difference produces twice the t. That second lever is why a trivial difference can be highly significant in a large study, and why an important difference can fail to reach significance in a small one. Statistical significance and practical importance are different questions, and only the effect size answers the second — Cohen's d, the difference divided by the standard deviation rather than by the standard error, is reported in the steps above for that reason.

The reference distribution is Student's t with n − 1 degrees of freedom rather than the normal, because you estimated the noise from the same small sample that produced the signal. That estimate is itself uncertain, and the t distribution's heavier tails are the price. If you somehow knew the population standard deviation, you would compare against the normal instead, and the critical value at 95% would be 1.960 regardless of n. You can look either value up with the t critical value calculator or the z critical value calculator.

Worked example: 25 components against a 500 MPa specification

A supplier's components are specified at 500 MPa mean tensile strength. You test 25 units, obtaining x̄ = 520 MPa and s = 50 MPa. You had no prior direction in mind, so the alternative is two-tailed at α = 0.05.

  1. Standard error. SE = 50/√25 = 50/5 = 10.000 MPa.
  2. Difference. x̄ − μ₀ = 520 − 500 = 20 MPa.
  3. t statistic. t = 20 / 10 = 2.000.
  4. Degrees of freedom. df = 25 − 1 = 24.
  5. Critical value. Two-tailed at α = 0.05 with df = 24, the table gives 2.0639.
  6. Compare. |t| = 2.000 < 2.0639, so you fail to reject H₀. The exact two-tailed p-value is 0.0567.
  7. Confidence interval for the difference. 20 ± 2.0639 × 10 = 20 ± 20.639, so −0.64 to 40.64 MPa.

Read the interval and the p-value together. The interval includes zero — which is exactly why the test does not reject — but only barely, and it also includes differences as large as 40 MPa. “Not significant” here means “this study cannot tell a real 20 MPa advantage from noise”, not “there is no advantage”. Cohen's d = 20/50 = 0.4, a moderate effect by conventional labels.

Now suppose you had tested 40 components with the same mean and standard deviation. SE becomes 50/√40 = 7.906, t becomes 2.530, df = 39, the two-tailed critical value is 2.023, and you would reject. Nothing about the components changed; only your ability to see the difference did.

Reading the output

Start with the confidence interval, not the verdict. The interval for the difference tells you the size of effect your data support. If the whole interval lies inside a range you would call unimportant, you have a genuinely negative result. If the interval is wide and spans both trivial and large effects, you have an inconclusive study whatever the p-value says.

Compare the p-value against the alpha you fixed before looking at the data. Alpha is your tolerance for a false positive: at α = 0.05, one in twenty tests of a true null will reject by chance. Choosing alpha after seeing the p-value, or running the test both ways and reporting the tail that worked, inflates that error rate in ways the number no longer reflects.

Check the direction if you ran a one-tailed test. A one-tailed test at α = 0.05 uses the 1.7109 cutoff at df = 24 rather than 2.0639, so it detects a difference in the nominated direction more easily. The price is absolute: a difference in the other direction cannot be declared significant no matter how large it is. Choose one-tailed only when a result in the opposite direction would lead to the same action as no result at all.

Watch the assumptions. The test needs independent observations, and it needs the sample mean to be roughly normally distributed — which the central limit theorem delivers for most data by about n = 30, but not for strongly skewed data or data with outliers at small n. If a single extreme value is driving your result, a rank-based alternative such as the Mann-Whitney family is more robust.

Critical values of t

Reject H₀ when your |t| exceeds the tabulated value. The one-tailed column applies when you fixed the direction in advance.
dfOne-tailed α = 0.05Two-tailed α = 0.05Two-tailed α = 0.01
52.0152.5714.032
91.8332.2623.250
101.8122.2283.169
141.7612.1452.977
191.7292.0932.861
241.7112.0642.797
291.6992.0452.756
491.6772.0102.680
991.6601.9842.626
1.6451.9602.576

Standard published Student t table. The bottom row is the normal distribution, which t approaches as df grows.

Ways a t-test goes wrong

  • Choosing the tail after seeing the data. A one-tailed test picked because the difference went that way is a two-tailed test with the alpha secretly doubled.
  • Reading a non-significant result as proof of no difference. Absence of evidence is not evidence of absence; the confidence interval tells you how much difference you have failed to rule out.
  • Testing many hypotheses and reporting the significant one. Twenty independent tests of true nulls produce, on average, one p-value below 0.05. Adjust for multiplicity or pre-register the primary outcome.
  • Treating paired data as one sample of independent values. Before-and-after measurements on the same subjects belong in a paired t-test, which tests the mean of the differences and is far more powerful.
  • Entering the standard error where the standard deviation belongs. The field wants s. Supplying an already-divided value inflates t by a factor of √n.
  • Ignoring the effect size. With n = 10,000, a difference of no practical consequence will be significant. Report Cohen's d or the raw difference with its interval alongside every p-value.

Which test to use instead

If you are comparing two independent groups rather than one group against a fixed number, use the two-sample t-test calculator. If the same subjects were measured twice, use the paired t-test calculator — which is really this one-sample test applied to the within-subject differences. For three or more groups, run a one-way ANOVA rather than a series of pairwise t-tests, which would inflate the false-positive rate.

If your outcome is a proportion rather than a mean, the t-test is the wrong tool; use a proportion test. If the data are ordinal, badly skewed, or dominated by outliers, a rank-based test makes fewer assumptions. And if you have a test statistic from elsewhere and simply want the tail area, the p-value calculator converts z, t, chi-square and F statistics directly.

Before running a study, decide how large a difference matters and check whether your planned sample can detect it. The statistical power calculator and the Cohen's d calculator turn that into a concrete number, and doing it in advance is far more useful than explaining a null result afterwards.

Key terms

Null hypothesis (H₀)
The claim that the population mean equals μ₀. The test never proves it; it either rejects it or fails to.
p-value
The probability of a result at least as extreme as the one observed, computed assuming H₀ is true.
Alpha (α)
The false-positive rate you accept in advance. Reject H₀ when p < α.
Cohen's d
The difference expressed in standard deviations rather than standard errors. Unlike t, it does not grow with sample size.

Frequently asked questions

What is a good t value?

There is no such thing in isolation — t only means something against its degrees of freedom. At df = 5 you need |t| above 2.571 to reject at the two-tailed 5% level; at df = 99 you need only 1.984, and at very large df the threshold settles at 1.960. Look up the row for your df in the table above, or read the critical value the calculator reports.

Should I use a one-tailed or two-tailed test?

Use two-tailed unless you decided the direction before collecting data and a difference in the opposite direction would lead to exactly the same action as no difference. Regulators and most journals expect two-tailed by default, because a one-tailed test is more likely to reject in the nominated direction and cannot reject at all in the other. Deciding after seeing the data is not a valid choice.

What sample size do I need for a t-test?

It depends on the effect size you want to detect, not on a fixed rule. To detect a difference of one half a standard deviation (d = 0.5) at 80% power and α = 0.05 two-tailed, a one-sample t-test needs about 34 observations; detecting d = 0.2 needs around 200. Work it out for your case with the statistical power calculator before you start, not after.

My p-value is 0.0567 — is that significant?

Not at α = 0.05, and the honest report is exactly that: p = 0.057, which does not clear the threshold you set. It is also not evidence of no effect. Report the p-value to three decimals, report the confidence interval for the difference, and let the reader see how close it is. Describing it as “marginally significant” or “approaching significance” converts a clear number into a rhetorical one.

Can I run a t-test with only 5 observations?

Yes, and the t distribution is designed for it — that is why Gosset developed it. The cost is power and the reliance on normality: at df = 4 you need |t| above 2.776 to reject at 5%, so only large effects will show. With five observations you also cannot check the normality assumption in any meaningful way, so the result depends on judgement about the measurement process rather than on the data.

What is the difference between this and a z-test?

The z-test uses a known population standard deviation σ; the t-test estimates it from the sample and widens the reference distribution to account for that extra uncertainty. In practice σ is essentially never known, so the t-test is the correct default. The two converge as the sample grows: at df = 99 the two-tailed 5% cutoff is 1.984 against z's 1.960.

Does a significant result mean the difference matters?

No. Significance says the difference is hard to explain by sampling noise; it says nothing about size. With a large enough sample, a difference of 0.1 MPa on a 500 MPa specification will be highly significant and completely irrelevant. Always read the effect size and the confidence interval beside the p-value, and decide in advance what size of difference would change your decision.

Why does the confidence interval sometimes disagree with the p-value?

It should not, when both use the same alpha and the same number of tails. A two-tailed test rejects at α exactly when the (1 − α) interval for the difference excludes zero — the two are algebraically the same statement. An apparent disagreement usually means you have run a one-tailed test while reading a two-sided interval, or changed alpha between the two.

References