ο»Ώ

t-test Calculator

Dominik Czernia

Physicist at the Institute of Nuclear Physics in KrakΓ³w interested in magnetism and always ready to explain everything to everyone in simple terms. He is currently working on adding more scientific papers to his collection, accompanied by his son and another baby on its way. A perfectionist with an acute eye for detail, he has a unit converter in his brain and uses it to compare prices at the supermarket. Loves peace and quiet, especially during hiking. See full profile

and Jack Bowater

Portrait of the calculator author

466 people find this calculator helpful

Table of contents

Welcome to our t-test calculator! Here you can not only easily perform one-sample t-tests, but also two-sample t-tests, as well as paired t-tests.

Do you prefer to find the p-value from t-test, or would you rather find the t-test critical values? Well, this t-test calculator can do both! 😊

What does a t-test tell you? Take a look at the text below, where we explain what actually gets tested when various types of t-tests are performed. Also, we explain when to use t-tests (in particular, whether to use the z-test vs. t-test) and what assumptions your data should satisfy for the results of a t-test to be valid. If you've ever wanted to know how to do a t-test by hand, we provide the necessary t-test formula, as well as tell you how to determine the number of degrees of freedom in a t-test.

When to use a t-test?

A t-test is one of the most popular statistical tests for location, i.e., it deals with the population(s) mean value(s).

There are different types of t-tests that you can perform:

In the next section, we explain when to use which.
Remember that a t-test can only be used for one or two groups. If you need to compare three (or more) means, use the analysis of variance (ANOVA) method.

The t-test is a parametric test, meaning that your data has to fulfill some assumptions:

If your sample doesn't fit these assumptions, you can resort to nonparametric alternatives. Visit our Mann–Whitney U test calculator or the Wilcoxon rank-sum test calculator to learn more. Other possibilities include the Wilcoxon signed-rank test or the sign test.

Which t-test?

Your choice of t-test depends on whether you are studying one group or two groups:

Number of degrees of freedom in t-test (one-sample) = n βˆ’ 1 n-1 n βˆ’ 1 .

Two-sample t-test

  1. The null hypothesis is that the actual difference between these groups' means, ΞΌ 1 \mu_1 ΞΌ 1 ​ , and ΞΌ 2 \mu_2 ΞΌ 2 ​ , is equal to some pre-set value, Ξ” \Delta Ξ” .
  2. The alternative hypothesis is that the difference ΞΌ 1 βˆ’ ΞΌ 2 \mu_1 - \mu_2 ΞΌ 1 ​ βˆ’ ΞΌ 2 ​ is:

In particular, if this pre-determined difference is zero ( Ξ” = 0 \Delta = 0 Ξ” = 0 ):

  1. The null hypothesis is that the population means are equal.
  2. The alternate hypothesis is that the population means are:

Formally, to perform a t-test, we should additionally assume that the variances of the two populations are equal (this assumption is called the homogeneity of variance).

There is a version of a t-test that can be applied without the assumption of homogeneity of variance: it is called a Welch's t-test. For your convenience, we describe both versions.

Two-sample t-test if variances are equal

Use this test if you know that the two populations' variances are the same (or very similar).

Two-sample t-test formula (with equal variances):

t = x Λ‰ 1 βˆ’ x Λ‰ 2 βˆ’ Ξ” s p β‹… 1 n 1 + 1 n 2 t = \frac_1 - \bar_2 - \Delta> +\frac >> t = s p ​ β‹… n 1 ​ 1 ​ + n 2 ​ 1 ​

​ x Λ‰ 1 ​ βˆ’ x Λ‰ 2 ​ βˆ’ Ξ” ​

where s p s_p s p ​ is the so-called pooled standard deviation, which we compute as:

s p = ( n 1 βˆ’ 1 ) s 1 2 + ( n 2 βˆ’ 1 ) s 2 2 n 1 + n 2 βˆ’ 2 s_p = \sqrt> s p ​ = n 1 ​ + n 2 ​ βˆ’ 2 ( n 1 ​ βˆ’ 1 ) s 1 2 ​ + ( n 2 ​ βˆ’ 1 ) s 2 2 ​ ​

Number of degrees of freedom in t-test (two samples, equal variances) = n 1 + n 2 βˆ’ 2 n_1 + n_2 - 2 n 1 ​ + n 2 ​ βˆ’ 2 .

Two-sample t-test if variances are unequal (Welch's t-test)

Use this test if the variances of your populations are different.

Two-sample Welch's t-test formula if variances are unequal:

t = x Λ‰ 1 βˆ’ x Λ‰ 2 βˆ’ Ξ” s 1 2 / n 1 + s 2 2 / n 2 t = \frac_1 - \bar_2 - \Delta>> t = s 1 2 ​ / n 1 ​ + s 2 2 ​ / n 2 ​

​ x Λ‰ 1 ​ βˆ’ x Λ‰ 2 ​ βˆ’ Ξ” ​

The number of degrees of freedom in a Welch's t-test (two-sample t-test with unequal variances) is very difficult to count. We can approximate it with the help of the following Satterthwaite formula:

( s 1 2 / n 1 + s 2 2 / n 2 ) 2 ( s 1 2 / n 1 ) 2 n 1 βˆ’ 1 + ( s 2 2 / n 2 ) 2 n 2 βˆ’ 1 \frac<(s_1^2/n_1 + s_2^2/n_2)^2><\frac<(s_1^2/n_1)^2> + \frac<(s_2^2/n_2)^2> > n 1 ​ βˆ’ 1 ( s 1 2 ​ / n 1 ​ ) 2 ​ + n 2 ​ βˆ’ 1 ( s 2 2 ​ / n 2 ​ ) 2 ​ ( s 1 2 ​ / n 1 ​ + s 2 2 ​ / n 2 ​ ) 2 ​

Alternatively, you can take the smaller of n 1 βˆ’ 1 n_1 - 1 n 1 ​ βˆ’ 1 and n 2 βˆ’ 1 n_2 - 1 n 2 ​ βˆ’ 1 as a conservative estimate for the number of degrees of freedom.

πŸ”Ž The Satterthwaite formula for the degrees of freedom can be rewritten as a scaled weighted harmonic mean of the degrees of freedom of the respective samples: n 1 βˆ’ 1 n_1 - 1 n 1 ​ βˆ’ 1 and n 2 βˆ’ 1 n_2 - 1 n 2 ​ βˆ’ 1 , and the weights are proportional to the standard deviations of the corresponding samples.

Paired t-test

As we commonly perform a paired t-test when we have data about the same subjects measured twice (before and after some treatment), let us adopt the convention of referring to the samples as the pre-group and post-group.

  1. The null hypothesis is that the true difference between the means of pre- and post-populations is equal to some pre-set value, Ξ” \Delta Ξ” .
  2. The alternative hypothesis is that the actual difference between these means is:

Typically, this pre-determined difference is zero. We can then reformulate the hypotheses as follows:

  1. The null hypothesis is that the pre- and post-means are the same, i.e., the treatment has no impact on the population.
  2. The alternative hypothesis:

Paired t-test formula

In fact, a paired t-test is technically the same as a one-sample t-test! Let us see why it is so. Let x 1 , . . . , x n x_1, . , x_n x 1 ​ , . , x n ​ be the pre observations and y 1 , . . . , y n y_1, . , y_n y 1 ​ , . , y n ​ the respective post observations. That is, x i , y i x_i, y_i x i ​ , y i ​ are the before and after measurements of the i -th subject.

For each subject, compute the difference, d i : = x i βˆ’ y i d_i := x_i - y_i d i ​ := x i ​ βˆ’ y i ​ . All that happens next is just a one-sample t-test performed on the sample of differences d 1 , . . . , d n d_1, . , d_n d 1 ​ , . , d n ​ . Take a look at the formula for the T-score:

t = x Λ‰ βˆ’ Ξ” s β‹… n t = \frac - \Delta>\cdot \sqrt t = s x Λ‰ βˆ’ Ξ” ​ β‹… n
  • Ξ” \Delta Ξ” β€” Mean difference postulated in the null hypothesis;
  • n n n β€” Size of the sample of differences, i.e., the number of pairs;
  • x Λ‰ \bar x Λ‰ β€” Mean of the sample of differences; and
  • s s s β€” Standard deviation of the sample of differences.
  • Number of degrees of freedom in t-test (paired): n βˆ’ 1 n - 1 n βˆ’ 1

    t-test vs Z-test

    We use a Z-test when we want to test the population mean of a normally distributed dataset, which has a known population variance. If the number of degrees of freedom is large, then the t-Student distribution is very close to N(0,1).

    Hence, if there are many data points (at least 30), you may swap a t-test for a Z-test, and the results will be almost identical. However, for small samples with unknown variance, remember to use the t-test because, in such cases, the t-Student distribution differs significantly from the N(0,1)!

    πŸ™‹ Have you concluded you need to perform the z-test? Head straight to our z-test calculator!

    What is a t-test?

    A t-test is a widely used statistical test that analyzes the means of one or two groups of data. For instance, a t-test is performed on medical data to determine whether a new drug really helps.

    What are different types of t-tests?

    Different types of t-tests are:

    1. One-sample t-test;
    2. Two-sample t-test; and
    3. Paired t-test.

    How to find the t value in a one sample t-test?

    To find the t-value:

    1. Subtract the null hypothesis mean from the sample mean value.
    2. Divide the difference by the standard deviation of the sample.
    3. Multiply the resultant with the square root of the sample size.