Statistics::ZTest Function

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

Z Test.

#NameTypeDescription
1DataTVec *The data samples to be analyzed.
2Meanconst doubleThe mean to value to compare the data to.
3Sigmaconst doubleThe standard deviation to compare the data to.
4hResTHypothesisResult &Returns the result of the null hypothesis (default assumption is that the means are equal).
5Signifdouble &(Significance level) returns the probability of observing the given result by chance given that the null hypothesis is true.
6ConfIntDewArray<double> &Returns the 100*(1-Alpha) percent confidence interval for the mean.
7hType = THypothesisType::htTwoTailedconst THypothesisTypeDefines the type of the null hypothesis (left, right and two - tailed).
8Alpha = 0.05const doubleDefines the desired significance level. If the significance probability (Signif) is bellow the desired significance (Alpha), the null hypothesis is rejected.

Returns: Z statistics.

Remarks:

Compares the normally distributed Data elements mean value with known standard deviation Sigma, to a mean value 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);
    d1.SetIt(false, DewArray<double>{ 3, 3.5, 2, 3.1, 10, 9 });
    double signif, ZStat;
    DewArray<double> ci(2);
    THypothesisResult hres;
    // don't use normal approximation
    ZStat = ZTest(d1, 5.0, 1.29, hres, signif, ci, THypothesisType::htTwoTailed, 0.05);
    // signif = 0.84940087229; hres = hrNotReject;
    // ci=[4.06780398958, 6.13219601041]
    // Comment : Since the SignRes is greater than Alpha (0.05), the
    // null hypothesis (H0) that data mean is equal to 5.1 cannot be rejected
    // the alternative (Ha) that data mean are NOT equal can therefore be
    // rejected
}
See Also: Statistics::tTest
Declared in Dew::Stats::Units::Statistics · Dew.Stats/Units.Statistics.h · Cross-compiler