The ** t-test** is any statistical hypothesis test in which the test statistic follows a Student's

A *t*-test is the most commonly applied when the test statistic would follow a normal distribution if the value of a scaling term in the test statistic were known. When the scaling term is unknown and is replaced by an estimate based on the data, the test statistics (under certain conditions) follow a Student's *t* distribution. The *t*-test can be used, for example, to determine if the means of two sets of data are significantly different from each other.

- 1 History
- 2 Uses
- 3 Assumptions
- 4 Unpaired and paired two-sample
*t*-tests - 5 Calculations
- 6 Worked examples
- 7 Related statistical tests
- 8 Software implementations
- 9 See also
- 10 References
- 11 Further reading
- 12 External links

Among the most frequently used *t*-tests are:

- A one-sample location test of whether the mean of a population has a value specified in a null hypothesis.
- A two-sample location test of the null hypothesis such that the means of two populations are equal. All such tests are usually called
**Student's**, though strictly speaking that name should only be used if the variances of the two populations are also assumed to be equal; the form of the test used when this assumption is dropped is sometimes called Welch's*t*-tests*t*-test. These tests are often referred to as "unpaired" or "independent samples"*t*-tests, as they are typically applied when the statistical units underlying the two samples being compared are non-overlapping.^{[16]}

Most test statistics have the form *t* = *Z*/*s*, where *Z* and *s* are functions of the data.

*Z* may be sensitive to the alternative hypothesis (i.e., its magnitude tends to be larger when the alternative hypothesis is true), whereas *s* is a scaling parameter that allows the distribution of *t* to be determined.

As an example, in the one-sample *t*-test

- $t={\frac {Z}{s}}={\frac {{\bar {X}}-\mu }{$
Gosset had been hired owing to Claude Guinness's policy of recruiting the best graduates from Oxford and Cambridge to apply biochemistry and statistics to Guinness's industrial processes.

^{[12]}Gosset devised the*t*-test as an economical way to monitor the quality of stout. The*t*-test work was submitted to and accepted in the journal*Biometrika*and published in 1908.^{[13]}Company policy at Guinness forbade its chemists from publishing their findings, so Gosset published his statistical work under the pseudonym "Student" (see Student's*t*-distribution for a detailed history of this pseudonym, which is not to be confused with the literal term*student*).Guinness had a policy of allowing technical staff leave for study (so-called "study leave"), which Gosset used during the first two terms of the 1906–1907 academic year in Professor Karl Pearson's Biometric Laboratory at University College London.

^{[14]}Gosset's identity was then known to fellow statisticians and to editor-in-chief Karl Pearson.^{[15]}Among the most frequently used

*t*-tests are:- A one-sample location test of whether the mean of a population has a value specified in a null hypothesis.
- A two-sample location test of the null hypothesis such t
Most test statistics have the form

*t*=*Z*/*s*, where*Z*and*s*are functions of the data.*Z*may be sensitive to the alternative hypothesis (i.e., its magnitude tends to be larger when the alternative hypothesis is true), whereas*s*is a scaling parameter that allows the distribution of*t*to be determined.As an example, in the one-sample

*t*-test- $t=\frac{Z}{s}=\frac{\overline{X}-\mu}{}$
*Z*may be sensitive to the alternative hypothesis (i.e., its magnitude tends to be larger when the alternative hypothesis is true), whereas*s*is a scaling parameter that allows the distribution of*t*to be determined.As an example, in the one-sample

*t*-testwhere

*X*is the sample mean from a sample*X*_{1},*X*_{2}, …,*X*_{n}, of size*n*,*s*is the standard error of the mean, ${\textstyle {\widehat {\sigma }}}$ is the estimate of the standard deviation of the population, and*μ*is the population mean.The assumptions underlying a

*t*-test in the simplest form above are that:*X*follows a normal distribution with mean*μ*and variance*σ*^{2}/*n**s*^{2}(*n*− 1)/*σ*^{2}follows a*χ*^{2}distribution with*n*− 1 degrees of freedom. This assumption is met when the observations used for estimating*s*^{2}come from a normal distribution (and i.i.d for each group).*Z*and*s*are independent.

In the

*t*-test comparing the means of two independent samples, the following assumptions should be met:- The means of the two populations being compared should follow normal distributions. Under weak assumptions, this follows in large samples from the central limit theorem, even when the distribution of observations in each group is non-normal.
^{[17]} - If using Student's original definit
The assumptions underlying a

*t*-test in the simplest form above are that:In the

*t*-test comparing the means of two independent samples, the following assumptions should be met:- The means of the two populations being compared should follow normal distributions. Under weak assumptions, this follows in large samples from the central limit theorem, even when the distribution of observations in each group is non-normal.
^{[17]} - If using Student's original definition of the
*t*-test, the two populations being compared should have the same variance (testable using*F*-test, Levene's test, Bartlett's test, or the Brown–Forsythe test; or assessable graphically using a Q–Q plot). If the sample sizes in the two groups being compared are equal, Student's original*t*-test is highly robust to the presence of unequal variances.^{[18]}Welch's*Most two-sample*[20]*t*-tests are robust to all but large deviations from the assumptions.^{}For exactness, the

*t*-test and*Z*-test require normality of the sample means, and the*t*-test additionally requires that the sample variance follows a scaled*χ*^{2}distribution, and that the sample mean and sample variance be statistically independent. Normality of the individual data values is not required if these conditions are met. By the central limit theorem, sample means of moderately large samples are often well-approximated by a normal distribution even if the data are not normally distributed. For non-normal data, the distribution of the sample variance may deviate substantially from a*χ*^{2}distribution. However, if the sample size is large, Slutsky's theorem implies that the distribution of the sample variance has little effect on the distribution of the test statistic.## Unpaired and paired two-sample

*t*-testsexactness, the*t*-test and*Z*-test require normality of the sample means, and the*t*-test additionally requires that the sample variance follows a scaled*χ*^{2}distribution, and that the sample mean and sample variance be statistically independent. Normality of the individual data values is not required if these conditions are met. By the central limit theorem, sample means of moderately large samples are often well-approximated by a normal distribution even if the data are not normally distributed. For non-normal data, the distribution of the sample variance may deviate substantially from a*χ*^{2}distribution. However, if the sample size is large, Slutsky's theorem implies that the distribution of the sample variance has little effect on the distribution of the test statistic.Two-sample

*t*-tests for a difference in mean involve independent samples (unpaired samples) or paired samples. Paired*t*-tests are a form of blocking, and have greater power than unpaired tests when the paired units are similar with respect to "noise factors" that are independent of membership in the two groups being compared.^{[21]}In a different context, paired*t*-tests can be used to reduce the effects of confounding factors in an observational study.### Independent (unpaired) samples

The independent samples

*t*-test is used when two separate sets of independent and identically distributed samples are obtained, one from each of the two populations being compared. For example, suppose we are evaluating the effect of a medical treatment, and we enroll 100 subjects into our study, then randomly assign 50 subjects to the treatment group and 50 subjects to the control group. In this case, we have two independent samples and would use the unpaired form of the*t*-test.### Paired samples

Main article: Paired difference testPaired samples

*t*-tests typically consist of a sample of matched pairs of similar units, or one group of units that has been tested twice (a "repeated measures"*t*-test).A typical example of the repeated measures

*t*-test would be where subjects are tested prior to a treatment, say for high blood pressure, and the same subjects are tested again after treatment with a blood-pressure-lowering medication. By comparing the same patient's numbers before and after treatment, we are effectively using each patient as their own control. That way the correct rejection of the null hypothesis (here: of no difference made by the treatment) can become mucThe independent samples

*t*-test is used when two separate sets of independent and identically distributed samples are obtained, one from each of the two populations being compared. For example, suppose we are evaluating the effect of a medical treatment, and we enroll 100 subjects into our study, then randomly assign 50 subjects to the treatment group and 50 subjects to the control group. In this case, we have two independent samples and would use the unpaired form of the*t*-test.### Paired samples

Main article: units, or one group of units that has been tested twice (a "repeated measures"*t*-test).A typical example of the repeated measures

*t*-test would be where subjects are tested prior to a treatment, say for high blood pressure, and the same subjects are tested again after treatment with a blood-pressure-lowering medication. By comparing the same patient's numbers before and after treatment, we are effectively using each patient as their own control. That way the correct rejection of the null hypothesis (here: of no difference made by the treatment) can become much more likely, wA typical example of the repeated measures

*t*-test would be where subjects are tested prior to a treatment, say for high blood pressure, and the same subjects are tested again after treatment with a blood-pressure-lowering medication. By comparing the same patient's numbers before and after treatment, we are effectively using each patient as their own control. That way the correct rejection of the null hypothesis (here: of no difference made by the treatment) can become much more likely, with statistical power increasing simply because the random interpatient variation has now been eliminated. However, an increase of statistical power comes at a price: more tests are required, each subject having to be tested twice. Because half of the sample now depends on the other half, the paired version of Student's*t*-test has only*n*/2 − 1 degrees of freedom (with*n*being the total number of observations). Pairs become individual test units, and the sample has to be doubled to achieve the same number of degrees of freedom. Normally, there are*n*− 1 degrees of freedom (with*n*being the total number of observations).^{[22]}A paired samples

*t*-test based on a "matched-pairs sample" results from an unpaired sample that is subsequently used to form a paired sample, by using additional variables that were measured along with the variable of interest.^{[23]}The matching is carried out by identifying pairs of values consisting of one observation from each of the two samples, where the pair is similar in terms of other measured variables. This approach is sometimes used in observational studies to reduce or eliminate the effects of confounding factors.Paired samples

*t*-tests are often referred to as "dependent samples*t*-tests".Explicit expressions that can be used to carry out various

*t*-tests are given below. In each case, the formula for a test statistic that either exactly follows or closely approximates a*t*-distribution under the null hypothesis is given. Also, the appropriate degrees of freedom are given in each case. Each of these statistics can be used to carry out either a one-tailed or two-tailed test.Once the

*t*value and degrees of freedom are determined, a*p*-value can be found using a table of values from Student's*t*-distribution. If the caOnce the

*t*value and degrees of freedom are determined, a*p*-value can be found using a table of values from Student's*t*-distribution. If the calculated*p*-value is below the threshold chosen for statistical significance (usually the 0.10, the 0.05, or 0.01 level), then the null hypothesis is rejected in favor of the alternative hypothesis.In testing the null hypothesis that the population mean is equal to a specified value

*μ*_{0}, one uses the statistic- $}where$${\bar {x}}$ is the sample mean,
*s*is the sample standard deviation and*n*is the sample size. The degrees of freedom used in this test are*n*− 1. Although the parent population does not need to be normally distributed, the distribution of the population of sample means ${\bar {x}}$ is assumed to be normal.By the central limit theorem, if the observations are independent and the second moment exists, then $t$ will be approximately normal N(0;1).

### Slope of a regression line

Suppose one is fitting the model

- $Y=\alpha +\beta x+\epsilon$
Let

Then

- $t_{\text{score}}={\frac {{\widehat {\beta }}-\beta _{0}}{SE_{\widehat {\beta }}}}\sim {\mathcal {T}}_{n-2}$

has a

*t*-distribution with*n*− 2 degrees of freedom if the null hypothesis is true. The standard error of the slope coefficient:- $S{E}_{\hat{\beta}}=has\; at-distribution\; with$
*n*− 2 degrees of freedom if the null hypothesis is true. The standard error of the slope coefficient:- $S{E}_{\hat{\beta}}=\frac{\sqrt{{\displaystyle \frac{1}{n-2}}{\displaystyle \sum _{i=1}^{n}{({y}_{i}-{\hat{y}}_{i}}^{}}}}{}$
can be written in terms of the residuals. Let

- $\begin{array}{rl}{\hat{\epsilon}}_{i}& ={y}_{i}-{\hat{y}}_{i}={y}_{i}-\left(\hat{\alpha}+\hat{\beta}{x}_{i}\right)=\text{residuals}=\text{estimated errors},\\ \text{SSR}& =\sum _{i=1}^{n}{{\hat{\epsilon}}_{i}}^{2}=Then\end{array}$
*t*_{score}is given by:- $t_{\text{score}}={\frac {\left({\widehat {\beta }}-\beta _{0}\right){\sqrt {n-2}}}{\sqrt {\frac {SSR}{\sum _{i=1}^{n}\left(x_{i}-{\bar {x}}\right)^{2}}}}}.$

Another way to determine the

*t*_{score}is:- $t_{\text{score}}={\frac {r{\sqrt {n-2}}}{\sqrt {1-r^{2}}}},$

where

*r*is the Pearson correlation coefficient.The

*t*_{score, intercept}can be determined from the*t*_{score, slope}:- $$
*t*_{score}is:- $t_{\text{score}}={\frac {r{\sqrt {n-2}}}{\sqrt {1-r^{2}}}},$

where

*r*is the Pearson correlation coefficient.The

*t*_{score, intercept}can be determined from the*t*_{score, slope}:- $t_{\text{score,intercept}}={\frac {\alpha }{\beta }}{\frac {t_{\text{score,slope}}}{\sqrt {s_{\text{x}}^{2}+{\bar {x}}^{2}}}}}where$
*r*is the Pearson correlation coefficient.The

*t*_{score, intercept}can be determined from the*t*_{score, slope}:- $s_{p}={\sqrt {\frac {s_{X_{1}}^{2}+s_{X_{2}}^{2}}{2}}}.$

- $\begin{array}{rl}{\hat{\epsilon}}_{i}& ={y}_{i}-{\hat{y}}_{i}={y}_{i}-\left(\hat{\alpha}+\hat{\beta}{x}_{i}\right)=\text{residuals}=\text{estimated errors},\\ \text{SSR}& =\sum _{i=1}^{n}{{\hat{\epsilon}}_{i}}^{2}=Then\end{array}$

- $S{E}_{\hat{\beta}}=\frac{\sqrt{{\displaystyle \frac{1}{n-2}}{\displaystyle \sum _{i=1}^{n}{({y}_{i}-{\hat{y}}_{i}}^{}}}}{}$

- $Y=\alpha +\beta x+\epsilon$

- $}where$${\bar {x}}$ is the sample mean,

- The means of the two populations being compared should follow normal distributions. Under weak assumptions, this follows in large samples from the central limit theorem, even when the distribution of observations in each group is non-normal.

- $t=\frac{Z}{s}=\frac{\overline{X}-\mu}{}$