Performs the two sample pooled or paired t-test.
function tTest(const Data1: TVec; const Data2: TVec; out hRes: THypothesisResult; out Signif: double; var ConfInt: TTwoElmReal; Paired: boolean = false; hType: THypothesisType = htTwoTailed; Alpha: double = 0.05): double; overload;
Parameters |
Description |
Data1 |
First set of data from which to compute the mean. |
Data2 |
Second set of data from which to compute the mean. |
hRes |
Returns the result of the null hypothesis (default assumption is that the means are equal). |
Signif |
(Significance level) returns the probability of observing the given result by chance given that the null hypothesis is true. |
ConfInt |
Returns the 100*(1-Alpha) percent confidence interval for the mean. |
Paired |
If true, tTest routine will perform Two-Sample Paired t-Test. If false, tTest will perform Two-Sample Pooled (unpaired) t-Test. |
hType |
Defines the type of the null hypothesis (left, right and two - tailed). |
Alpha |
Defines the desired significance level. If the significance probability (Signif) is bellow the desired significance (Alpha), the null hypothesis is rejected. |
The T-test statistics.
It compares Data1 mean value with Data2 mean value. The assumption is Data1 and Data2 variances are equal, but unknown. The null hypothesis is that Data1 mean is equal to Data2 mean.
In this example we'll try to confirm hypothesis that first sample mean is smaller from second sample mean.
Uses Math387, MtxExpr, Statistics; procedure Example; var d1,d2: Vector; Signif : double; HypRes : THypothesisResult; MeanCI : TTwoElmReal; begin d1.SetIt(false,[2, 3, 5, 2.5]); // mean = 3.125 d2.SetIt([5, 7, 8]); // mean = 6.6666666667 tTest(d1,d2, HypRes, Signif, MeanCI, false, htLeftTailed); // Signif = 0.01070092300; HypRes = hrReject; // MeanCI=[ -5.702239060933, +INF ] // Comment : Since the signf is smaller than Alpha (0.05), the // null hypothesis (H0) that data means are equal is rejected and // the alternative (Ha) that d1 mean is smaller than d2 mean // CANNOT be rejected end;
#include "MtxExpr.hpp" #include "Math387.hpp" #include "Statistics.hpp" void __fastcall Example() { sVector d1,d2; d1.SetIt(false, OPENARRAY(double, (2, 3, 5, 2.5))); // mean = 3.125 d2.SetIt(false, OPENARRAY(double,(5, 7, 8))); // mean = 6.6666666667 double signif, TStat; double ci[2]; THypothesisResult hres; // don't use normal approximation TStat = TTest(d1,d2,hres,signif,ci,false,htLeftTailed,0.05); // signif = 0.01070092300; hres = hrReject; // ci=[ -5.702239060933, +INF ] // Comment : Since the Signif is smaller than Alpha (0.05), the // null hypothesis (H0) that data means are equal is rejected and // the alternative (Ha) that d1 mean is smaller than d2 mean // CANNOT be rejected }
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
|
What do you think about this topic? Send feedback!
|