Statistics::ShapiroWilks Function

double ShapiroWilks(TVec *Data, THypothesisResult &hRes, double &Signif, THypothesisType hType = THypothesisType::htTwoTailed, double Alpha = 0.05);

The Shapiro-Wilks test for normality of data.

#NameTypeDescription
1DataTVec *Data vector, containing ordered and unique deviates from unknown distribution. Data Length must be betweeen 3 and 5000, otherwise an execption is raised.
2hResTHypothesisResult &Returns the result of the null hypothesis (default assumption is that data comes from normal distribution).
3Signifdouble &(Significance level) returns the probability of observing the given result by chance given that the null hypothesis is true.
4hType = THypothesisType::htTwoTailedTHypothesisTypeDefines the type of the null hypothesis (left, right and two - tailed).
5Alpha = 0.05doubleDefines the desired significance level. If the significance probability (Signif) is bellow the desired significance (Alpha), the null hypothesis is rejected.

Returns: the Shapiro-Wilks statistics.

Remarks:

Performs the The Shapiro-Wilks test for normality of data.

Note
Basic assumption is Data values i.e. deviates from unknown distribution are ordered and unique.

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

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

void Example()
{
    Vector a(0);
    Vector b(0);
    a.Size(1000, false);
    RandomWeibull(2.5, 1.0, a, -1);
    // filter original data, retain only sorted unique values
    Unique(a, b, nullptr);
    THypothesisResult hres;
    double sign;
    ShapiroWilks(b, hres, sign, THypothesisType::htTwoTailed, 0.05);
    // Significance approx. 0
    // hres = hrReject -> data is not coming from normal distribution
}
See Also: Statistics::Unique, Statistics::ShapiroFrancia
Declared in Dew::Stats::Units::Statistics · Dew.Stats/Units.Statistics.h · Cross-compiler