what is a t test 
a t test is an inferential statistic used to determine if there is a significant difference between the means of two groups and how they are related t tests are used when the data sets follow a normal distribution and have unknown variances like the data set recorded from flipping a coin 100 times the t test is a test used for hypothesis testing in statistics and uses the t statistic the t distribution values and the degrees of freedom to determine statistical significance investopedia sabrina jiangunderstanding the t testa t test compares the average values of two data sets and determines if they came from the same population in the above examples a sample of students from class a and a sample of students from class b would not likely have the same mean and standard deviation similarly samples taken from the placebo fed control group and those taken from the drug prescribed group should have a slightly different mean and standard deviation mathematically the t test takes a sample from each of the two sets and establishes the problem statement it assumes a null hypothesis that the two means are equal using the formulas values are calculated and compared against the standard values the assumed null hypothesis is accepted or rejected accordingly if the null hypothesis qualifies to be rejected it indicates that data readings are strong and are probably not due to chance the t test is just one of many tests used for this purpose statisticians use additional tests other than the t test to examine more variables and larger sample sizes for a large sample size statisticians use a z test other testing options include the chi square test and the f test using a t testconsider that a drug manufacturer tests a new medicine following standard procedure the drug is given to one group of patients and a placebo to another group called the control group the placebo is a substance with no therapeutic value and serves as a benchmark to measure how the other group administered the actual drug responds after the drug trial the members of the placebo fed control group reported an increase in average life expectancy of three years while the members of the group who are prescribed the new drug reported an increase in average life expectancy of four years initial observation indicates that the drug is working however it is also possible that the observation may be due to chance a t test can be used to determine if the results are correct and applicable to the entire population four assumptions are made while using a t test the data collected must follow a continuous or ordinal scale such as the scores for an iq test the data is collected from a randomly selected portion of the total population the data will result in a normal distribution of a bell shaped curve and equal or homogenous variance exists when the standard variations are equal t test formulacalculating a t test requires three fundamental data values they include the difference between the mean values from each data set or the mean difference the standard deviation of each group and the number of data values of each group this comparison helps to determine the effect of chance on the difference and whether the difference is outside that chance range the t test questions whether the difference between the groups represents a true difference in the study or merely a random difference the t test produces two values as its output t value and degrees of freedom the t value or t score is a ratio of the difference between the mean of the two sample sets and the variation that exists within the sample sets the numerator value is the difference between the mean of the two sample sets the denominator is the variation that exists within the sample sets and is a measurement of the dispersion or variability this calculated t value is then compared against a value obtained from a critical value table called the t distribution table higher values of the t score indicate that a large difference exists between the two sample sets the smaller the t value the more similarity exists between the two sample sets a large t score or t value indicates that the groups are different while a small t score indicates that the groups are similar degrees of freedom refer to the values in a study that has the freedom to vary and are essential for assessing the importance and the validity of the null hypothesis computation of these values usually depends upon the number of data records available in the sample set the correlated t test or paired t test is a dependent type of test and is performed when the samples consist of matched pairs of similar units or when there are cases of repeated measures for example there may be instances where the same patients are repeatedly tested before and after receiving a particular treatment each patient is being used as a control sample against themselves this method also applies to cases where the samples are related or have matching characteristics like a comparative analysis involving children parents or siblings the formula for computing the t value and degrees of freedom for a paired t test is t mean 1 mean 2 s diff n where mean 1 and mean 2 the average values of each of the sample sets s diff the standard deviation of the differences of the paired data values n the sample size the number of paired differences n 1 the degrees of freedom begin aligned t frac textit mean 1 textit mean 2 frac s text diff sqrt n textbf where textit mean 1 text and textit mean 2 text the average values of each of the sample sets s text diff text the standard deviation of the differences of the paired data values n text the sample size the number of paired differences n 1 text the degrees of freedom end aligned t n s diff mean1 mean2 where mean1 and mean2 the average values of each of the sample setss diff the standard deviation of the differences of the paired data valuesn the sample size the number of paired differences n 1 the degrees of freedom the equal variance t test is an independent t test and is used when the number of samples in each group is the same or the variance of the two data sets is similar the formula used for calculating t value and degrees of freedom for equal variance t test is t value mean 1 mean 2 n 1 1 var 1 2 n 2 1 var 2 2 n 1 n 2 2 1 n 1 1 n 2 where mean 1 and mean 2 average values of each of the sample sets var 1 and var 2 variance of each of the sample sets n 1 and n 2 number of records in each sample set begin aligned text t value frac textit mean 1 textit mean 2 sqrt frac n1 1 times textit var 1 2 n2 1 times textit var 2 2 n1 n2 2 times frac 1 n1 frac 1 n2 textbf where textit mean 1 text and textit mean 2 text average values of each text of the sample sets textit var 1 text and textit var 2 text variance of each of the sample sets n1 text and n2 text number of records in each sample set end aligned t value n1 n2 2 n1 1 var12 n2 1 var22 n11 n21 mean1 mean2 where mean1 and mean2 average values of eachof the sample setsvar1 and var2 variance of each of the sample setsn1 and n2 number of records in each sample set and degrees of freedom n 1 n 2 2 where n 1 and n 2 number of records in each sample set begin aligned text degrees of freedom n1 n2 2 textbf where n1 text and n2 text number of records in each sample set end aligned degrees of freedom n1 n2 2where n1 and n2 number of records in each sample set the unequal variance t test is an independent t test and is used when the number of samples in each group is different and the variance of the two data sets is also different this test is also called welch s t test the formula used for calculating t value and degrees of freedom for an unequal variance t test is t value m e a n 1 m e a n 2 v a r 1 n 1 v a r 2 n 2 where m e a n 1 and m e a n 2 average values of each of the sample sets v a r 1 and v a r 2 variance of each of the sample sets n 1 and n 2 number of records in each sample set begin aligned text t value frac mean1 mean2 sqrt bigg frac var1 n1 frac var2 n2 bigg textbf where mean1 text and mean2 text average values of each text of the sample sets var1 text and var2 text variance of each of the sample sets n1 text and n2 text number of records in each sample set end aligned t value n1var1 n2var2 mean1 mean2 where mean1 and mean2 average values of eachof the sample setsvar1 and var2 variance of each of the sample setsn1 and n2 number of records in each sample set and degrees of freedom v a r 1 2 n 1 v a r 2 2 n 2 2 v a r 1 2 n 1 2 n 1 1 v a r 2 2 n 2 2 n 2 1 where v a r 1 and v a r 2 variance of each of the sample sets n 1 and n 2 number of records in each sample set begin aligned text degrees of freedom frac left frac var1 2 n1 frac var2 2 n2 right 2 frac left frac var1 2 n1 right 2 n1 1 frac left frac var2 2 n2 right 2 n2 1 textbf where var1 text and var2 text variance of each of the sample sets n1 text and n2 text number of records in each sample set end aligned degrees of freedom n1 1 n1var12 2 n2 1 n2var22 2 n1var12 n2var22 2 where var1 and var2 variance of each of the sample setsn1 and n2 number of records in each sample set 