Skip to content

T-Test Calculator - Free Online Statistical Analysis Tool

Free t-test calculator. Enter sample data to get the t-statistic, degrees of freedom, and p-value for one-sample, two-sample, and paired t-tests instantly.

Enter comma-separated numerical values for the sample

Loading calculator...
πŸ“š

Documentation

What Is a T-Test?

A t-test is a statistical method that checks whether the average of a set of numbers is meaningfully different from another average, or from a fixed value. It is also called Student's t-test. Researchers use it to compare two groups, such as a treatment group and a control group, or to compare one group against a known standard.

The test produces a number called the t-statistic. A t-statistic far from zero suggests the averages really differ. A t-statistic close to zero suggests any difference could just be random noise.

Types of T-Tests

This calculator supports three kinds of t-test.

  • One-sample t-test: compares the mean of one sample against a known or hypothesized value.
  • Two-sample t-test: compares the means of two independent samples, such as two separate groups of people. This calculator uses Welch's t-test, which does not assume the two groups spread out by the same amount.
  • Paired t-test: compares two sets of measurements taken from the same subjects, such as scores before and after a treatment.

How to Use This T-Test Calculator

  1. Choose a test type: one-sample, two-sample, or paired.
  2. Enter the data.
    • One-sample: enter the sample values, separated by commas, and the population mean to test against.
    • Two-sample: enter both samples as separate comma-separated lists.
    • Paired: enter the pairs in the form (x1,y1), (x2,y2), and so on.
  3. Set a significance level, commonly 0.05.
  4. Select Calculate to see the t-statistic, the degrees of freedom, and the p-value.

To judge significance, compare the p-value with the significance level. If the p-value is less than or equal to the significance level, the difference is considered statistically significant.

T-Test Formula

One-Sample T-Test Formula

t=xΛ‰βˆ’ΞΌ0s/nt = \frac{\bar{x} - \mu_0}{s / \sqrt{n}}

xΛ‰\bar{x} is the sample mean, ΞΌ0\mu_0 is the value being tested against, ss is the sample standard deviation, and nn is the sample size. Degrees of freedom: df=nβˆ’1df = n - 1.

Two-Sample T-Test Formula (Welch's Test)

t=xΛ‰1βˆ’xΛ‰2s12n1+s22n2t = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{\dfrac{s_1^2}{n_1} + \dfrac{s_2^2}{n_2}}}

Degrees of freedom come from the Welch–Satterthwaite equation:

df=(s12n1+s22n2)2(s12/n1)2n1βˆ’1+(s22/n2)2n2βˆ’1df = \frac{\left(\dfrac{s_1^2}{n_1} + \dfrac{s_2^2}{n_2}\right)^2}{\dfrac{(s_1^2/n_1)^2}{n_1 - 1} + \dfrac{(s_2^2/n_2)^2}{n_2 - 1}}

This formula usually gives a df that is not a whole number.

Paired T-Test Formula

t=dˉsd/nt = \frac{\bar{d}}{s_d / \sqrt{n}}

dΛ‰\bar{d} is the mean of the differences between each pair, sds_d is the standard deviation of those differences, and nn is the number of pairs. Degrees of freedom: df=nβˆ’1df = n - 1.

How to Calculate a T-Test: Worked Example

A manufacturer claims a battery lasts 50 hours on average. A tester checks nine batteries and records these lifespans, in hours:

51, 49, 52, 48, 50, 47, 53, 49, 51

Step 1: State the hypotheses. Null hypothesis: the true mean is 50 hours. Alternative hypothesis: the true mean is not 50 hours.

Step 2: Find the sample mean.

xˉ=51+49+52+48+50+47+53+49+519=50.00\bar{x} = \frac{51+49+52+48+50+47+53+49+51}{9} = 50.00

Step 3: Find the sample standard deviation. The deviations from the mean are 1, -1, 2, -2, 0, -3, 3, -1, 1. Squared, they are 1, 1, 4, 4, 0, 9, 9, 1, 1, which sum to 30.

s=309βˆ’1=3.75β‰ˆ1.94s = \sqrt{\frac{30}{9-1}} = \sqrt{3.75} \approx 1.94

Step 4: Find the t-statistic.

t=50.00βˆ’501.94/9=0.00t = \frac{50.00 - 50}{1.94 / \sqrt{9}} = 0.00

Step 5: Find the degrees of freedom.

df=9βˆ’1=8df = 9 - 1 = 8

Step 6: Find the p-value. At t=0t = 0 and df=8df = 8, the two-tailed p-value is 1.00.

Step 7: Draw a conclusion. Since 1.00 is greater than 0.05, there is not enough evidence that the average battery life differs from 50 hours.

T-Test Assumptions

A t-test gives reliable results only when a few conditions roughly hold.

  • Normality: the data should be roughly bell-shaped, especially in small samples.
  • Independence: each observation should not affect any other observation.
  • Random sampling: the data should come from a random sample of the population being studied.

For a paired t-test, these conditions apply to the differences between pairs, not to the raw scores. For larger samples, roughly above 30, a t-test tends to stay accurate even when the data is not perfectly bell-shaped, because of a statistical property called the central limit theorem.

Alternatives to the T-Test

When the assumptions above do not hold, other tests can be used instead.

  • Mann-Whitney U test: a non-parametric alternative to the two-sample t-test.
  • Wilcoxon signed-rank test: a non-parametric alternative to the paired t-test.
  • ANOVA: compares the means of three or more groups at once, rather than just two.

History of the T-Test

William Sealy Gosset developed the t-test in 1908 while working as a chemist at the Guinness brewery in Dublin. Guinness did not allow staff to publish research under their own names, so Gosset used the pen name "Student." That is why the method is often called Student's t-test. He created it to judge whether small batches of brewing ingredients met quality standards, using only a handful of samples at a time.

Frequently Asked Questions

What is a t-test used for?

A t-test checks whether the average of a sample is significantly different from another average or from a fixed value. It is common in medicine, psychology, education, and business research.

When should I use a one-sample, two-sample, or paired t-test?

Use a one-sample t-test to compare a sample mean with a known value. Use a two-sample t-test to compare two separate, unrelated groups. Use a paired t-test when the same subjects are measured twice, such as before and after a treatment.

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

A t-test is used when the sample is small or the population standard deviation is unknown. A z-test is used for large samples when the population standard deviation is known. In practice, the t-test is used far more often because the population standard deviation is rarely known in advance.

How do I interpret a p-value from a t-test?

The p-value is the probability of seeing a difference this large, or larger, if there were actually no real difference. A small p-value, typically at or below 0.05, suggests the observed difference is unlikely to be due to chance alone.

What is Welch's t-test?

Welch's t-test is a version of the two-sample t-test that does not require the two groups to have equal variance. This calculator always uses Welch's method for two-sample tests, since it stays accurate whether or not the two groups vary by the same amount.

What is degrees of freedom in a t-test?

Degrees of freedom is a number, based on sample size, that fixes the exact shape of the t-distribution used to find the p-value. For a one-sample or paired t-test, degrees of freedom equals sample size minus 1. Welch's two-sample t-test uses a formula that usually produces a value that is not a whole number.

References

  1. Gosset, W. S. (1908). "The Probable Error of a Mean." Biometrika, 6(1), 1–25.
  2. NIST/SEMATECH e-Handbook of Statistical Methods, Section 1.3.6.7.2, "Critical Values of the Student's t Distribution."