Statistics::tTest Function

Overload List

#SignatureDescription
1double tTest(TVec *Data, double Mean, THypothesisResult &hRes, double &Signif, DewArray<double> &ConfInt, const THypothesisType hType = THypothesisType::htTwoTailed, const double Alpha = 0.05);One or two sample paired or pooled T-test.
2double tTest(TVec *Data1, TVec *Data2, THypothesisResult &hRes, double &Signif, DewArray<double> &ConfInt, bool Paired = false, THypothesisType hType = THypothesisType::htTwoTailed, double Alpha = 0.05);Performs the two sample pooled or paired t-test.

Overload 1: double tTest(TVec *Data, double Mean, THypothesisResult &hRes, double &Signif, DewArray<double> &ConfInt, const THypothesisType hType = THypothesisType::htTwoTailed, const double Alpha = 0.05);

One or two sample paired or pooled T-test.

#NameTypeDescription
1DataTVec *
2Meandouble
3hResTHypothesisResult &
4Signifdouble &
5ConfIntDewArray<double> &
6hType = THypothesisType::htTwoTailedconst THypothesisType
7Alpha = 0.05const double
Remarks:

Performs the one sample T-test. It compares Data mean value with the Mean. The null hypothesis is that Data mean value is equal to the Mean.

Examples
#include "MtxExpr.h"
#include "Statistics.h"
#include "Units.Statistics.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Stats;
using namespace Dew::Stats::Units::Statistics;

void Example()
{
    Vector d1, d2;
    double Signif;
    THypothesisResult HypRes;
    DewArray<double> MeanCI(2);

    d1.SetIt(false,DewArray<double>{2, 3, 5, 2.5}); // mean = 3.125
    d2.SetIt(DewArray<double>{5, 7, 8}); // mean = 6.6666666667
    tTest(d1,d2, HypRes, Signif, MeanCI, false, THypothesisType::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
}
Declared in Dew::Stats::Units::Statistics · Dew.Stats/Units.Statistics.h · Cross-compiler

Overload 2: double tTest(TVec *Data1, TVec *Data2, THypothesisResult &hRes, double &Signif, DewArray<double> &ConfInt, bool Paired = false, THypothesisType hType = THypothesisType::htTwoTailed, double Alpha = 0.05);

Performs the two sample pooled or paired t-test.

#NameTypeDescription
1Data1TVec *First set of data from which to compute the mean.
2Data2TVec *Second set of data from which to compute the mean.
3hResTHypothesisResult &Returns the result of the null hypothesis (default assumption is that the means are equal).
4Signifdouble &(Significance level) returns the probability of observing the given result by chance given that the null hypothesis is true.
5ConfIntDewArray<double> &Returns the 100*(1-Alpha) percent confidence interval for the mean.
6Paired = falseboolIf true, tTest routine will perform Two-Sample Paired t-Test. If false, tTest will perform Two-Sample Pooled (unpaired) t-Test.
7hType = THypothesisType::htTwoTailedTHypothesisTypeDefines the type of the null hypothesis (left, right and two - tailed).
8Alpha = 0.05doubleDefines the desired significance level. If the significance probability (Signif) is bellow the desired significance (Alpha), the null hypothesis is rejected.

Returns: The T-test statistics.

Remarks:

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.

Examples
#include "MtxExpr.h"
#include "Statistics.h"
#include "Units.Statistics.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Stats;
using namespace Dew::Stats::Units::Statistics;

void Example()
{
    Vector d1(0);
    Vector d2(0);
    d1.SetIt(false, DewArray<double>{2, 3, 5, 2.5}); // mean = 3.125
    d2.SetIt(false, DewArray<double>{5, 7, 8}); // mean = 6.6666666667
    double signif, TStat;
    DewArray<double> ci(2);
    THypothesisResult hres;
    // don't use normal approximation
    TStat = tTest(d1,d2,hres,signif,ci,false,THypothesisType::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
}
See Also: Statistics::ZTest
Declared in Dew::Stats::Units::Statistics · Dew.Stats/Units.Statistics.h · Cross-compiler