DataLab is a compact statistics package aiming at exploratory data analysis. Please visit the DataLab Web site for more information....

## Perform2SampleTTest

Declaration: Perform2SampleTTest (Data1, Data2: TDoubleArray; TestType: TtTestVersion; OneSided: boolean; var Mean1, Mean2, Stdv1, Stdv2, MeanDiff, StdDiff, tStatistic: double; var df: integer): double;
The function Perform2SampleTTest returns the probability associated with a 2-sample t-test (probability which indicates the likelihood that two samples have come from the same two underlying populations having the same mean).

The parameters Data1 and Data2 contain the data. Note that the number of elements of the two data arrays have to be equal if a paired t-test is to be performed. The parameter TestType determines the type of t-test to be performed. The parameter OneSided has to be TRUE for one-sided tests, or FALSE for two-sided tests.

The function returns additional parameters obtained during the t-test calculation:

 Mean1, Mean2 means of the two samples Stdv1, Stdv2 standard deviations of the two samples MeanDiff mean of paired differences (only available if TestType is ttPaired) StdDiff standard deviation of paired differences (only available if TestType is ttPaired) tStatistic t statistic df degrees of freedom

 Hint 1: If the TestType is set to ttHeteroScedastic the Welch approximation is used yielding probabilities which are slightly different to the results compared to the results of Microsofts Excel. The slightly different probabilities have no practical consequences since the Welch approximation is (too) conservative in most instances.

 Hint 2: Some background information on t-tests can be found in the ebook "Fundamentals of Statistics"