T-Test Calculator

Compare Sample Means

Enter the data for your samples to perform a t-test.

t-value Probability Density -t +t

How to Perform a T-Test

A t-test is a statistical method used to determine if there is a significant difference between the means of two groups or between a sample mean and a known or hypothesized population mean. It's a crucial tool in hypothesis testing and is widely used in various fields of research.

Formulas and Their Meanings

The formula for a t-test depends on whether it's a single sample or two sample test:

1. Single Sample T-Test:

\[t = \frac{\bar{x} - \mu_0}{s / \sqrt{n}}\]

Where:

  • \(\bar{x}\) is the sample mean
  • \(\mu_0\) is the hypothesized population mean
  • \(s\) is the sample standard deviation
  • \(n\) is the sample size

2. Two Sample T-Test:

\[t = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{s_p^2(\frac{1}{n_1} + \frac{1}{n_2})}}\]

Where:

  • \(\bar{x}_1\) and \(\bar{x}_2\) are the means of the two samples
  • \(s_p^2\) is the pooled variance
  • \(n_1\) and \(n_2\) are the sizes of the two samples

The pooled variance is calculated as:

\[s_p^2 = \frac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2}{n_1 + n_2 - 2}\]

Calculation Steps

  1. Determine the type of t-test (single sample or two sample).
  2. Calculate the mean(s) of the sample(s).
  3. Calculate the standard deviation(s) of the sample(s).
  4. For a two sample test, calculate the pooled variance.
  5. Calculate the t-statistic using the appropriate formula.
  6. Determine the degrees of freedom.
  7. Calculate the p-value using the t-distribution.
  8. Compare the p-value to the significance level to make a decision about the null hypothesis.

Example Calculation

Let's perform a single sample t-test with the following data:

  • Sample data: 22, 25, 18, 20, 23
  • Hypothesized population mean (\(\mu_0\)): 20
  • Significance level (\(\alpha\)): 0.05
  1. Calculate the sample mean:
    \(\bar{x} = \frac{22 + 25 + 18 + 20 + 23}{5} = 21.6\)
  2. Calculate the sample standard deviation:
    \(s = \sqrt{\frac{\sum(x_i - \bar{x})^2}{n - 1}} = 2.702\)
  3. Calculate the t-statistic:
    \(t = \frac{21.6 - 20}{2.702 / \sqrt{5}} = 1.323\)
  4. Degrees of freedom: \(df = n - 1 = 4\)
  5. Calculate the p-value (using a t-distribution table or calculator):
    \(p = 0.256\) (two-tailed)
  6. Compare p-value to significance level:
    Since 0.256 > 0.05, we fail to reject the null hypothesis.

Conclusion: There is not enough evidence to conclude that the sample mean is significantly different from the hypothesized population mean of 20.

Visual Representation

t-value Probability Density -2.776 2.776 t = 1.323

This diagram illustrates the t-distribution for the example calculation. The green line represents the calculated t-statistic (1.323). The red shaded areas represent the critical regions based on the significance level (0.05). Since the green line falls outside the red areas, we fail to reject the null hypothesis.