The Shapiro-Wilks test for normality of data.
function ShapiroWilks(const Data: TVec; out hRes: THypothesisResult; out Signif: double; hType: THypothesisType = htTwoTailed; Alpha: double = 0.05): double;
Parameters |
Description |
Data |
Data vector, containing ordered and unique deviates from unknown distribution. Data Length must be betweeen 3 and 5000, otherwise an execption is raised. |
hRes |
Returns the result of the null hypothesis (default assumption is that data comes from normal distribution). |
Signif |
(Significance level) returns the probability of observing the given result by chance given that the null hypothesis is true. |
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 Shapiro-Wilks statistics.
Performs the The Shapiro-Wilks test for normality of data.
Basic assumption is Data values i.e. deviates from unknown distribution are ordered and unique.ΕΎ
In this example we'll use ShapiroWilks test to determine if data is coming from normal distribution.
Uses MtxExpr, Math387, Statistics; procedure Example; var avec,bvec: Vector; hres: THypothesisResult; Signif: double; begin avec.Size(1000,false); RandomWeibull(2.5,1,avec); // filter original data, retain only sorted unique values Unique(avec,bvec); ShapiroWilks(bvec,hres,signif); // Significance approx. 0 // hres = hrReject -> data is not coming from normal distribution end;
#include "MtxExpr.hpp" #include "Math387.hpp" #include "Statistics.hpp" void __fastcall Example() { sVector a,b; a.Size(1000,false); RandomWeibull(2.5,1.0,a); // filter original data, retain only sorted unique values Unique(a,b, NULL); THypothesisResult hres; double sign; ShapiroWilks(b,hres, sign,htTwoTailed,0.05); // Significance approx. 0 // hres = hrReject -> data is not coming from normal distribution }
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
|
What do you think about this topic? Send feedback!
|