Introduction
Ttest is a statistical hypothesis test, used for the comparison of two data sets. In other words, ttest shows us whether the difference between two population’s averages is
real or only by chance due to a random variation. Ttest can also be used to analyse the mean of a population compared to a reference value. The latter is called one sample ttest.
Under the pseudonym "Student", William Sealy Gosset, a chemist and statistician, working for Guiness in Dublin, Ireland started to apply the ttest for statistical analysis, and
published it in 1908. He used this statistical technique to evaluate the quality of the beer in serial production.
Ttest is an inferential statistic, which means inferences can be drawn from the results and can be forwarded to the whole population of products. That's why it is very useful
in
quality management. According to StatTrek.com, the t distribution (Student's tdistribution) is a probability distribution that is
used to estimate population parameters when the sample size is small (below 30) and / or when the population variance is unknown (Remark: Otherwise we can use ztest). The t statistic produced can be associated
with a unique cumulative probability. This cumulative probability represents the likelihood of finding a sample mean less than or equal to a reference mean or another group's mean.
Such as in other statistical tests, we set up our nullhypothesis and alternative hypothesis with a given confidence level. "A tvalue of 0 indicates that the sample results
exactly equal the null hypothesis. As the difference between the sample data and the null hypothesis increases, the absolute value of the tvalue increases."  Minitab
Hypothesis 0 (nullhypothesis): we have no statistical evidence to reject the null hypothesis, so...
 [onesample test] there is no evidence, that the mean of the data set is statistically far from the reference value
 [twosample test] the means of the two population are statistically equal, as we see no statistical difference between the two groups (two data sets)
Hypothesis A (alternative hypothesis): we reject the null hypothesis, so...
 [onesample test] the mean of the tested data set is statistically far from the reference value
 [twosample test] the two population means differ from each other, as we see statistical difference between the two groups (two data sets)
The truth is, no hypothesis test is 100% reliable and certain, as two types of errors are possible. These are called Type I and Type II errors.
Type I error occurs, when we reject the null hypothesis, although it is true. From quality and manufacturing point of view, it means we scrap a product, because we think it is
defective, but finally it is not!
Having a Type II error is the inverse of Type I: we do not reject the false null hypothesis. In quality standpoint it means that we do not reject the product, even it is
defective. To make it more visible and understandable, the following table summarizes the situation possibilities.
Type I and Type II errors 

Null Hypothesis is True (alternative hypothesis is False) 
Null Hypothesis is False (alternative hypothesis is True) 
Fail to reject H_{0} 
Correct Decision (True Negative)  fail to reject H_{0} when it is true (probability = 1  α)
"We accept the good product" 
Type II Error (False Negative)  fail to reject H_{0} when it is false (probability = β)
"We accept the defective product, meaning we have an
inefficient test coverage" 
Rejecting H_{0} 
Type I Error (False Positive)  rejecting H_{0} when it is true (probability = α)
"We reject the good product, meaning we have an overreacting
test / measurement system" 
Correct Decision (True Positive)  rejecting H_{0} when it is false (probability = 1  β)
"We reject the defective product" 
The α value means the significance of the test. If we choose alpha = 0.05, it means we are willing to take 5% risk to make a Type I error. The β value represents the chance of
having a Type II error, meaning the power of the test is equal to 1  β.
Source: qMindset.com; minitab.com; encyclopedia.com; encyclopediaofmath.org; ocw.mit.edu; stattrek.com
Key Features
Benefits of ttest for quality are clear. For example you can use it for comparing samples from different production timeframes, substantiating your decision.
Ttest calculates with the difference of means (or difference between the group mean and the reference in case of onesample test), the variance of the groups (S^{2}) and
the sample size (n).
Onesample ttest
The purpose of onesample ttest is to check if the mean of the group is statistically the same as the reference value (nullhypothesis), or it is different (alternative
hypothesis).
Calculation formulae of onesample ttest (Source: qMindset.com)
Example: we check if the data set is statistically different from the reference value. The reference height of our part is 10.00 mm.
The measured values are:
Measured values 
10.01 
10.02 
9.99 
10.10 
10.05 
9.98 
10.04 
10.10 
9.97 
9.99 
10.10 
10.01 
10.03 
10.02 
9.95 
10.02 
10.01 
10.10 
10.06 
9.98 
Group statistics 
Statistic 
Value 
Reference value (µ) 
10.00 mm 
Standard deviation of data set (S) 
0.046143 
Sample size (n) 
20 
Degrees of freedom (df = n – 1) 
19 
Mean of data set (x̄) 
10.0265 mm 
T value 
2.57 
P value 
0.019 
Interpreting the results: based on the twotailed test, with 5% significance, there is a 95% chance that the true mean is between 10.005 and 10.048. According to the Ttest
table, the T value should be less, than 2.093 (with degrees of freedom = 19 and significance level = 0.05). As our T value is 2.57 (bigger than 2.093) and our p value is less than 0.05, we can state, that the
mean of the data set is significantly different from the reference value (10.0265 mm vs 10.00 mm).
Twosample unpaired test (independent samples)
The purpose of twosample ttest is to check if the means of two groups are reliably (significantly) different. With this test we compare two groups that are independent from
each other. During the test, we calculate with the means (x̄_{1}; x̄_{2}), the standard deviations (S_{1}; S_{2}), the sample sizes (n_{1}; n_{2}), and the
pooled variance (S_{p}^{2}), by using the following formula:
Calculation formulae of twosample unpaired ttest (Source: qMindset.com)
Example: we check if the two independent groups (data sets) are statistically different from each other.
The measured values are:
Measured values of group 1 
10 
12 
12 
11 
14 
9 
10 
11 
12 
10 
Measured values of group 2 
11 
10 
11 
12 
12 
13 
10 
9 
10 
10 
Group statistics 

Group 1 
Group 2 
Standard deviation of data set (S) 
1.4491 
1.2293 
Sample size (n) 
10 
10 
Degrees of freedom (df = n_{1} + n_{2}  2) 
18 
Mean of data set (x̄) 
11.1 
10.8 
T value 
0.4992 
P value 
0.624 
Interpreting the results: our absolute T value is small (0.4992), being under the critical T value, which is 2.1009, and our P value is 0.624 (so being above 0.05), which gives
no statistical evidence to reject the nullhypothesis. In practice this means that there is no significant difference between the group averages (means), so the two groups are statistically similar.
Twosample paired test (dependent samples)
The purpose of twosample ttest is to check if the means of two groups are reliably (significantly) different. With the paired test we compare two dependent data sets (e.g.
evaluating the same parts "before" and "after", or on "temperature 1" and "temperature 2"). During the test, we calculate with the mean of differences between pairs (d̄), the standard deviation of differences
(S_{d}), and the sample size (n), by using the following formula:
Calculation formulae of twosample paired ttest (Source: qMindset.com)
Example: we check if the two dependent groups (data sets) are statistically different from each other.
The measured values are:
Measured values of group 1 
10 
10 
11 
11 
14 
10 
10 
11 
12 
10 
Measured values of group 2 
12 
12 
13 
13 
16 
12 
13 
13 
14 
12 
Paired differences 
2 
2 
2 
2 
2 
2 
3 
2 
2 
2 
Group statistics 

Group 1 
Group 2 
Standard deviation of data set (S) 
1.2867 
1.2472 
Standard deviation of paired differences (S_{d}) 
0.3162 
Sample size (n) 
10 
10 
Degrees of freedom (df = n  1) 
9 
Mean of data set (x̄) 
10.9 
13.0 
Observed difference (absolute) 
2.1 
T value 
21.0018 
P value 
0.001 
Interpreting the results: our absolute T value is large (21.0018), being over the critical T value, which is 2.262, and our P value is below 0.001 (so being under 0.05), which
gives a clear statistical evidence to reject the nullhypothesis and conclude the acceptance of alternative hypothesis. In practice this means that there is a significant difference between the group averages
(means), so the two groups are statistically different.
Source: qMindset.com
Hints
The tdistribution varies based on degrees of freedom. As the degrees of freedom is based on the sample size, it drastically affects your T value. Larger sample size is better, as it increases the reliability of the test.
The probability density function of the Tdistribution (Source: minitab.com)
You can use ttest for various purposes in quality management:
 Onesample ttest for evaluating the bias of your measurement gauge, in the frame of Measurement System Analysis (MSA).
 Twosample unpaired ttest for comparing different subgroups, produced in different timeframes in your production.
 Twosample paired ttest for comparing the values of the same group, measured under different conditions (e.g. different temperature or before / after comparison, etc.).
Source: qMindset.com; minitab.com
Summary
 Ttest is a statistical hypothesis test, used for the comparison of two data sets (twosample ttest).
 Ttest can also be used to analyse the mean of a population compared to a reference value (onesample ttest).
 William Sealy Gosset, a chemist and statistician, working for Guiness in Dublin, Ireland started to apply the ttest for statistical analysis, and published it in 1908. He used the ttest to analyse
the quality of beer in serial production.
 The T value formula is different for various ttest types (onesample, twosample paired, twosample unpaired).
 Ttest is an inferential statistic, which means inferences can be drawn from the results and can be forwarded to the whole population of products.
 Ttest calculates with the difference of means (or difference between the group mean and the reference in case of onesample test), the variance of the groups (S^{2}) and the sample size (n).
 The tdistribution varies based on degrees of freedom, so a larger sample size gives more reliable conclusion.
Source: qMindset.com; minitab.com