BedrockCalculator
Figures cited to primary sourcesWritten by Aapt Dubey, MBA (Marketing & Banking), ISB 4 primary sourcesLast updated

T-Test Calculator: One-Sample t, P-Value and Confidence Interval

The T-Test Calculator: One-Sample t, P-Value and Confidence Interval runs a one-sample t-test from raw data or summary statistics: t statistic, degrees of freedom, p-value, critical t and a confidence interval for the mean.

Quick Answer: For the data 5.1, 4.9, 5.6, 5.8, 6.0, 5.2, 5.5, 5.7 tested against a mean of 5, the two-tailed p-value is 0.0092: t is 3.563 with 7 degrees of freedom, and the 95% confidence interval for the mean runs from 5.160 to 5.790.

Assumptions

Computed

Preset scenarios

p-value
0.00917642
t statistic
3.5634944
Degrees of freedom
7
Critical t
±2.3646243
Decision
Reject the null hypothesis at the 0.05 level (p < 0.05)
Confidence interval for the mean
5.1598047 to 5.7901953 (95%)
Margin of error
0.31519525
Sample mean
5.475
Sample standard deviation
0.37701838
Standard error
0.13329613
Sample size
8

Two-sided critical t-values at 95% confidence

Download CSV
Each row is this calculator run in summary mode with the sample size shown (degrees of freedom n - 1) at 95% confidence, two-tailed. Critical values are from the exact t distribution, shown to 8 significant figures.
Sample sizeDegrees of freedomCritical t
21±12.706205
32±4.3026527
43±3.1824463
54±2.7764451
65±2.5705818
87±2.3646243
109±2.2621572
1110±2.2281389
1615±2.1314495
2120±2.0859634
2625±2.0595386
3130±2.0422725
4140±2.0210754
6160±2.0002978
101100±1.9839715
1,0011000±1.9623391

This table and its CSV are free to reuse with a link to this page, CC BY 4.0.

T-Test Calculator: One-Sample t, P-Value and Confidence Interval: p-value 0.00917642 (I have: The raw data; Data (raw data mode): 5.1, 4.9, 5.6, 5.8, 6.0, 5.2, 5.5, 5.7; Hypothesised mean (μ₀): 5; Confidence level: 95% (significance 0.05); Alternative hypothesis: Two-tailed: mean is not μ₀).

Save or share this result

A one-page summary of this calculator's default example, drawn from the same calculation as the result above.

The infographic is free to reuse with a link to this page, CC BY 4.0.

Illustration of glass bottles and a flask holding liquid at slightly different levels, with a glass pipette in front
Quick Answer: For the data 5.1, 4.9, 5.6, 5.8, 6.0, 5.2, 5.5, 5.7 tested against a mean of 5, the two-tailed p-value is 0.0092: t is 3.563 with 7 degrees of freedom, and the 95% confidence interval for the mean runs from 5.160 to 5.790.

What does this calculator do?

This t-test calculator runs a one-sample t-test: it asks whether the mean of a sample is consistent with a hypothesised value, μ₀. It returns the t statistic, the degrees of freedom, the p-value for a two-tailed, right-tailed or left-tailed test, the critical t, a plain-language decision, and a confidence interval for the mean.

You can give it the raw data or just three summary numbers: the sample mean, the sample standard deviation and the sample size. Either way, the calculation follows the NIST/SEMATECH e-Handbook of Statistical Methods, which defines the test statistic, the n - 1 degrees of freedom and the confidence limits used here.

The t distribution is evaluated exactly for whole degrees of freedom, by a finite series rather than a numerical approximation, and the critical values agree with the NIST/SEMATECH table of the t distribution at every entry checked.

Using the T-Test Calculator

  1. Choose raw data or summary statistics.
  2. Enter the data, or the mean, standard deviation (the n - 1 version) and sample size.
  3. Enter the hypothesised mean μ₀, the value you are testing against.
  4. Pick the confidence level (90%, 95% or 99%) and the alternative hypothesis: two-tailed if any difference matters, right-tailed if you only care whether the mean is larger, left-tailed if only smaller.
  5. Read the p-value at the top and the decision below it. The interval card always shows a two-sided interval at the chosen confidence.

How is this calculated?

  1. Summarise the sample. In raw data mode, the mean and the sample standard deviation (dividing the sum of squared deviations by n - 1) are computed exactly from the list. In summary mode they are taken as entered.
  1. Standard error and t statistic. The standard error is the sample standard deviation divided by the square root of n. The t statistic is the distance from the sample mean to μ₀ in standard errors, with n - 1 degrees of freedom.

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

  1. Evaluate the t distribution. With θ = arctan(|t| / √ν), the probability that |T| is below |t| is a finite sum in powers of cos θ (Abramowitz and Stegun 26.7.3 for odd ν, 26.7.4 for even ν). For one degree of freedom it reduces to 2θ/π.

A(t|ν) = sin θ(1 + 1/2 cos ²θ + 1⋅3/2⋅4 cos ⁴θ + ⋯) (ν even)

  1. p-value. The upper tail is (1 - A)/2. A right-tailed p-value is the area above t, a left-tailed one the area below t, and a two-tailed one twice the area beyond |t|.

p_two = 1 − A(|t||ν)

  1. Critical t. With α equal to 1 minus the confidence level, the critical value is the t with an upper tail of α/2 for a two-tailed test and α for a one-tailed test. For 1 and 2 degrees of freedom it comes from the closed forms (tan(π(p - 1/2)) for one degree of freedom). Otherwise it starts from the Cornish-Fisher approximation and is refined by Newton's method on the exact distribution, using the t density with its gamma function ratio built exactly for whole ν, until the change is far below the digits shown.
  1. Confidence interval. The two-sided interval is the sample mean plus and minus the critical t for α/2 times the standard error, as in NIST/SEMATECH section 1.3.5.2. The margin of error card shows that half-width.

x̄ ± t_(1 − α/2, ν) s/√n

  1. Decision. If the p-value is below α, the null hypothesis is rejected at that level; otherwise it is not rejected. Values are shown with t to 8 significant figures and probabilities to 6, rounded half up.

Worked Example

The default data is eight measurements: 5.1, 4.9, 5.6, 5.8, 6.0, 5.2, 5.5, 5.7, tested against μ₀ = 5 at 95% confidence, two-tailed.

  1. Mean: 5.475. Sample standard deviation: 0.37701838.
  2. Standard error: 0.37701838 ÷ √8 = 0.13329613.
  3. t = (5.475 - 5) ÷ 0.13329613 = 3.5634944, with 7 degrees of freedom.
  4. Two-tailed p-value: 0.00917642. That is below 0.05, so the null hypothesis that the true mean is 5 is rejected at the 0.05 level.
  5. Critical t for 95%, two-tailed, 7 degrees of freedom: ±2.3646243. The t statistic is beyond it, which is the same conclusion.
  6. 95% confidence interval: 5.1598047 to 5.7901953. The interval does not contain 5.

The Mean 5.2, SD 0.4, n 16 preset is a summary-statistics example. The standard error is 0.1, so t = 2 with 15 degrees of freedom. The two-tailed p-value is 0.063945, not significant at 0.05, and the interval 4.986855 to 5.413145 contains 5. The Right-tailed version of the same numbers halves the p-value to 0.0319725, which is significant: a one-tailed test needs a smaller t to reach significance, which is why it should be chosen before looking at the data, not after.

How Do You Find Degrees of Freedom for a T-Test?

For a one-sample t-test, the degrees of freedom are the sample size minus one. A sample of 8 has 7; a sample of 16 has 15. One degree is used up because the deviations are measured from the sample's own mean, which forces them to add to zero, so only n - 1 of them are free to vary.

Two-sample and paired tests have their own rules, described below under what this calculator does not do.

Critical T-Values at 95% Confidence

The reference table lists the two-sided 95% critical values for common sample sizes. For 2 observations (1 degree of freedom) the critical value is 12.706205, for 11 (10 degrees of freedom) it is 2.2281389, and by 1,001 it has fallen to 1.9623391, close to the normal distribution's 1.96. These agree with the NIST/SEMATECH table, which prints 12.706, 2.228 and so on to three decimals.

What does this calculator not account for?

  • Two samples. Comparing the means of two independent groups needs a two-sample t-test (pooled or Welch). That is not computed here.
  • Paired data. For before-and-after measurements on the same subjects, subtract each pair and run this one-sample test on the differences against μ₀ = 0. That is exactly a paired t-test.
  • Normality. The test assumes the data come from a roughly normal distribution, or that the sample is large enough for the mean to be close to normal. With small, strongly skewed samples the p-value can mislead. Nothing here checks the assumption.
  • Known population standard deviation. If σ is known rather than estimated, the z-test applies; use the z-score calculator with the standard error as the standard deviation.
  • Sample size limits. Sample sizes from 2 to 5,000 are accepted, which keeps the exact series fast enough to run as you type.
  • Effect size and power. The p-value says nothing about how large or important a difference is, and no power analysis is done.

What mistakes do people make with this?

  • Choosing the tail after seeing the data. Switching to a one-tailed test because the two-tailed p-value missed 0.05 doubles the real false-positive rate.
  • Entering the population standard deviation. The test uses the sample standard deviation, s, with n - 1 in the divisor.
  • Reading "do not reject" as "proved equal". A non-significant result means the data are consistent with μ₀, not that the mean equals μ₀.
  • Treating the interval and the test as unrelated. A two-sided test at α rejects exactly when the (1 - α) interval excludes μ₀.
  • Rounding the standard deviation too much. In summary mode, enter the standard deviation with as many digits as you have.

Frequently Asked Questions

What is a t-test used for?

To decide whether a sample mean differs from a hypothesised value by more than chance would explain, when the population standard deviation has to be estimated from the sample.

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

A z-test uses a known population standard deviation and the normal distribution. A t-test estimates the standard deviation from the sample and uses the t distribution, which has heavier tails to allow for that extra uncertainty. As the sample grows, t approaches z.

How do I get a confidence interval for a mean?

Enter the data or the summary statistics and read the interval card. The value of μ₀ does not affect the interval; only the confidence level does.

What does the p-value mean?

It is the probability of getting a t statistic at least as extreme as the one observed if the true mean really were μ₀. A small p-value is evidence against μ₀.

Is 0.05 the right significance level?

It is a convention, not a law. Choose the level before running the test, based on how costly a false positive would be.

Sources

Did this calculator answer your question?

How this calculator is tested

This calculator is checked by 6 automated test cases: specific inputs whose correct result is known in advance, and rules the output must always obey. They run on every change to the site. See the testing and corrections policy.

Show the test cases
  • Default data: t = 3.5634944 with 7 df, p = 0.00917642
  • summary statistics: mean 5.2, SD 0.4, n 16 against 5 gives t = 2
  • one-tailed tests halve the p-value and use t(0.95)
  • a 99% interval uses t(0.995, 7) = 3.499 from the NIST table
  • rejects samples it cannot test
  • builds the critical value table from compute(), matching the NIST table

Add This Website as Preferred Source on Google

See Bedrock Calculator first in your Search results & AI Overviews