ttest Calculator
Welcome to our ttest calculator! Here you can not only easily perform onesample ttests, but also twosample ttests, as well as paired ttests. Do you prefer to find the pvalue from ttest, or would you rather find the ttest critical values? Well, this ttest calculator can do both! 😊
What does a ttest tell you? Take a look at the text below, where we explain what actually gets tested when various types of ttests are performed. Also, we explain when to use ttests (in particular, whether to use the ztest vs. ttest), and what assumptions your data should satisfy for the results of a ttest to be valid. If you've ever wanted to know how to do a ttest by hand, we provide the necessary ttest formula, as well as giving the number of degrees of freedom in a ttest.
When to use a ttest?
A ttest 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 ttests that you can perform:
 a onesample ttest;
 a twosample ttest; and
 a paired ttest.
In the next section we explain when to use which. Remember that a ttest 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 ttest is a parametric test, meaning that your data has to fulfill some assumptions:
 the data points are independent; AND
 the data, at least approximately, follow a normal distribution.
If your sample doesn't fit these assumptions, you can resort to a nonparametric alternatives, e.g., the Mann–Whitney U test (a.k.a. the Wilcoxon ranksum test), the Wilcoxon signedrank test or the sign test.
Which ttest?
Your choice of ttest depends on whether you are studying one group or two groups:

One sample ttest
Choose the onesample ttest to check if the mean of a population is equal to some preset hypothesized value.
Examples:
 The average volume of a drink sold in 0.33 l cans  is it really equal to 330 ml?
 The average weight of people from a specific city  is it different from the national average?

Twosample ttest
Choose the twosample ttest to check if the difference between the means of two populations is equal to some predetermined value, when the two samples have been chosen independently of each other.
In particular, you can use this test to check whether the two groups are different from one another.
Examples:
 The average difference in weight gain in two groups of people: one group was on a highcarb diet and the other on a highfat diet.
 The average difference in the results of a math test from students at two different universities.
This test is sometimes referred to as an independent samples ttest, or an unpaired samples ttest.

Paired ttest
A paired ttest is used to investigate the change in the mean of a population before and after some experimental intervention, based on a paired sample, i.e., when each subject has been measured twice: before and after treatment.
In particular, you can use this test to check whether, on average, the treatment has had any effect on the population.
Examples:

The change in student test performance before and after taking a course.

The change in blood pressure in patients before and after administering some drug.

How to do a ttest?
So, you've decided which ttest to perform. These next steps will tell you how to calculate the pvalue from ttest or its critical values, and then which decision to make about the null hypothesis.

Decide on the alternative hypothesis:

Use a twotailed ttest if you only care whether the population's mean (or, in the case of two populations, the difference between the populations' means) agrees or disagrees with the preset value.

Use a onetailed ttest if you want to test whether this mean (or difference in means) is greater/less than the preset value.


Compute your tscore value:
Formulas for the test statistic in ttests include the sample size, as well as its mean and standard deviation. The exact formula depends on the ttest type  check the sections dedicated to each particular test for more details.

Determine the degrees of freedom for the ttest:
The degrees of freedom are the number of observations in a sample that are free to vary as we estimate statistical parameters. In the simplest case, the number of degrees of freedom equals your sample size minus the number of parameters you need to estimate. Again, the exact formula depends on the ttest you want to perform  check the sections below for details.
The degrees of freedom are essential, as they determine the distribution followed by your tscore (under the null hypothesis). If there are d
degrees of freedom, then the distribution of the test statistics is the tStudent distribution with d
degrees of freedom. This distribution has a shape similar to N(0,1) (bellshaped and symmetric) but has heavier tails. If the number of degrees of freedom is large (>30), which generically happens for large samples, the tStudent distribution is practically indistinguishable from N(0,1).
Do you know that...
the tStudent distribution owes its name to William Sealy Gosset, who, in 1908, published his paper on the ttest under the pseudonym "Student". Gosset worked at the famous Guinness Brewery in Dublin, Ireland, and devised the ttest as an economical way to monitor the quality of beer. 🍺🍺🍺
pvalue from ttest
Recall that the pvalue is the probability (calculated under the assumption that the null hypothesis is true) that the test statistic will produce values at least as extreme as the tscore produced for your sample. As probabilities correspond to areas under the density function, pvalue from ttest can be nicely illustrated with the help of the following pictures:
The following formulae say how to calculate pvalue from ttest. By cdf_{t,d}
we denote the cumulative distribution function of the tStudent distribution with d
degrees of freedom:

pvalue from lefttailed ttest:
pvalue = cdf_{t,d}(t_{score})

pvalue from righttailed ttest:
pvalue = 1  cdf_{t,d}(t_{score})

pvalue from twotailed ttest:
pvalue = 2 * cdf_{t,d}(−t_{score})
or, equivalently:
pvalue = 2  2 * cdf_{t,d}(t_{score})
However, the cdf of the tdistribution is given by a somewhat complicated formula. To find the pvalue by hand, you would need to resort to statistical tables, where approximate cdf values are collected, or to specialized statistical software. Fortunately, our ttest calculator determines the pvalue from ttest for you in the blink of an eye!
ttest critical values
Recall, that in the critical values approach to hypothesis testing, you need to set a significance level, α, before computing the critical values, which in turn give rise to critical regions (a.k.a. rejection regions).
Formulas for critical values employ the quantile function of tdistribution, i.e., the inverse of the cdf:

Critical value for lefttailed ttest:
cdf_{t,d}^{1}(α)
critical region:
(∞, cdf_{t,d}^{1}(α)]

Critical value for righttailed ttest:
cdf_{t,d}^{1}(1α)
critical region:
[cdf_{t,d}^{1}(1α), ∞)

Critical values for twotailed ttest:
±cdf_{t,d}^{1}(1α/2)
critical region:
(∞, cdf_{t,d}^{1}(1α/2)] ∪ [cdf_{t,d}^{1}(1α/2), ∞)
To decide the fate of the null hypothesis, just check if your tscore lies within the critical region:

If your tscore belongs to the critical region, reject the null hypothesis and accept the alternative hypothesis.

If your tscore is outside the critical region, then you don't have enough evidence to reject the null hypothesis.
How to use our ttest calculator?

Choose the type of ttest you wish to perform:
 a onesample ttest (to test the mean of a single group against a hypothesized mean);
 a twosample ttest (to compare the means for two groups); or
 a paired ttest (to check how the mean from the same group changes after some intervention).

Decide on the alternative hypothesis:
 twotailed;
 lefttailed; or
 righttailed.

This ttest calculator allows you to use either the pvalue approach or the critical regions approach to hypothesis testing!

Enter your tscore, and the number of degrees of freedom. If you don't know them, provide some data about your sample(s): sample size, mean, and standard deviation, and our ttest calculator will compute the tscore and degrees of freedom for you.

Once all the parameters are present, the pvalue, or critical region, will immediately appear underneath the ttest calculator, along with an interpretation!
Onesample ttest

The null hypothesis is that the population mean is equal to some value
μ_{0}
. 
The alternative hypothesis is that the population mean is:
 different from
μ_{0}
;  smaller than
μ_{0}
; or  greater than
μ_{0}
.
 different from
Onesample ttest formula:
μ_{0}
is the mean postulated in H₀;n
is sample size;x̄
is the sample mean; ands
is sample standard deviation.
Number of degrees of freedom in ttest (onesample) = n1
Twosample ttest

The null hypothesis is that the actual difference between these groups' means,
μ₁
andμ₂
, is equal to some preset value,Δ
. 
The alternative hypothesis is that the difference
μ₁  μ₂
is: different from
Δ
;  smaller than
Δ
; or  greater than
Δ
.
 different from
In particular, if this predetermined difference is zero (Δ = 0
):

The null hypothesis is that the population means are equal.

The alternate hypothesis is that the population means are:
μ₁
andμ₂
are different from one another;μ₁
is smaller thanμ₂
; andμ₁
is greater thanμ₂
.
Formally, to perform a ttest, 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 ttest which can be applied without the assumption of homogeneity of variance: it is called a Welch's ttest. For your convenience, we describe both versions.
Twosample ttest if variances are equal
Use this test if you know that the two populations' variances are the same (or very similar).
Twosample ttest formula (with equal variances):
where sₚ
is the socalled pooled standard deviation, which we compute as:
and
Δ
is the mean difference postulated in H₀;n₁
is the first sample size;x̄₁
is the mean for the first sample;s₁
is the standard deviation in the first sample;n₂
is the second sample size;x̄₂
is the mean for the second sample; ands₂
is the standard deviation in the second sample.
Number of degrees of freedom in ttest (two samples, equal variances) = n₁ + n₂  2
.
Twosample ttest if variances are unequal (Welch's ttest)
Use this test if the variances of your populations are different.
Twosample Welch's ttest formula if variances are unequal:
where:

Δ
is the mean difference postulated in H₀; 
n₁
is the first sample size; 
x̄₁
is the mean for the first sample; 
s₁
is the standard deviation in the first sample; 
n₂
is the second sample size; 
x̄₂
is the mean for the second sample; and 
s₂
is the standard deviation in the second sample.
The number of degrees of freedom in a Welch's ttest (twosample ttest with unequal variances) is very difficult to count. We can be approximate it with help of the following Satterthwaite formula:
Alternatively, you can take the smaller of n₁  1
and n₂  1
as a conservative estimate for the number of degrees of freedom.
Do you know that...
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
and n₂1
, and the weights are proportional to the standard deviations of the corresponding samples.
Paired ttest
As we commonly perform a paired ttest 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 pregroup and postgroup.

The null hypothesis is that the true difference between the means of pre and post populations is equal to some preset value,
Δ
. 
The alternative hypothesis is that the actual difference between these means is:
 different from
Δ
;  smaller than
Δ
; or  greater than
Δ
.
 different from
Typically, this predetermined difference is zero. We can then reformulate the hypotheses as follows:

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

The alternative hypothesis:
 The pre and post means are different from one another (treatment has some effect);
 The pre mean is smaller than post mean (treatment increases the result); or
 The pre mean is greater than post mean (treatment decreases the result).
Paired ttest formula
In fact, a paired ttest is technically the same as a onesample ttest! Let us see why it is so. Let x_{1}, ... , x_{n}
be the pre observations and y_{1}, ... , y_{n}
the respective post observations. That is, 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}
. All that happens next is just a onesample ttest performed on the sample of differences d_{1}, ... , d_{n}
. Take a look at the formula for the tscore:

Δ
is the mean difference postulated in H₀; 
n
is the size of the sample of differences, i.e., the number of pairs; 
x̄
is the mean of the sample of differences; and 
s
is the standard deviation of the sample of differences.
Number of degrees of freedom in ttest (paired): n  1
ttest vs Ztest
We use a Ztest 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 tStudent distribution is very close to N(0,1).
Hence, if there are many data points (at least 30), you may swap a ttest for a Ztest, and the results will be almost identical. However, for small samples with unknown variance, remember to use the ttest because, in such case, the tStudent distribution differs significantly from the N(0,1)!
Done with the ttest? Try other statistical calculators from Omni's wide collection:
FAQ
What is a ttest?
A ttest is a widely used statistical test to compare the means of two groups of data. For instance, A test is performed for data generated from two experiments to gather insights on the results obtained from independent or interdependent experiments.
What are different types of ttests?
Different types of ttests are
 Single Ttest,
 Twosample Ttest, and
 Paired Ttest
The type of test is chosen based on whether the two groups to be tested are dependent on each other or not, the type of distribution, and conditions.
How to find t value in one sample ttest?
To find the t value:
 Subtract the null hypothesis mean from the sample mean value.
 Divide the difference by the standard deviation of the sample.
 Multiply the resultant with the square root of the sample size.