The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



Perform2SampleTTest


Unit:SDL_statis
Class: none
Declaration: [1] function Perform2SampleTTest (Data1, Data2: TVector; TestType: TtTestVersion; OneSided: boolean): double;
[2] function Perform2SampleTTest (Data1, Data2: TVector; 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). It is available in two overloaded versions: version [1] mimics the function TTEST of Microsofts Excel, version [2] returns a lot more details of the t-test calculation.

The parameters Data1 and Data2 contain the data as a TVector. Note that the number of elements of the two vectors 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.

Version [2] of 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 (critical value)
df degrees of freedom

Hint: 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: Some background information on t-tests can be found in the ebook "Fundamentals of Statistics"



Last Update: 2012-Oct-20