naginterfaces.library.stat.test_shapiro_wilk¶
- naginterfaces.library.stat.test_shapiro_wilk(x, a=None)[source]¶
test_shapiro_wilk
calculates Shapiro and Wilk’s statistic and its significance level for testing Normality.For full information please refer to the NAG Library document for g01dd
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g01/g01ddf.html
- Parameters
- xfloat, array-like, shape
The ordered sample values, , for .
- aNone or float, array-like, shape , optional
If has been set to then before entry must contain the weights as calculated in a previous call to
test_shapiro_wilk
, otherwise need not be set.
- Returns
- afloat, ndarray, shape
The weights required to calculate .
- wfloat
The value of the statistic, .
- pwfloat
The significance level of .
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, elements of not in order. , , .
- (errno )
On entry, all elements of are equal.
- Notes
test_shapiro_wilk
calculates Shapiro and Wilk’s statistic and its significance level for any sample size between and . It is an adaptation of the Applied Statistics Algorithm AS R94, see Royston (1995). The full description of the theory behind this algorithm is given in Royston (1992).Given a set of observations sorted into either ascending or descending order (
sort.realvec_sort
may be used to sort the data) this function calculates the value of Shapiro and Wilk’s statistic defined as:where is the sample mean and , for , are a set of ‘weights’ whose values depend only on the sample size .
On exit, the values of , for , are only of interest should you wish to call the function again to calculate and its significance level for a different sample of the same size.
It is recommended that the function is used in conjunction with a Normal plot of the data. Functions
normal_scores_exact()
andnormal_scores_approx()
can be used to obtain the required Normal scores.
- References
Royston, J P, 1982, Algorithm AS 181: the test for normality, Appl. Statist. (31), 176–180
Royston, J P, 1986, A remark on AS 181: the test for normality, Appl. Statist. (35), 232–234
Royston, J P, 1992, Approximating the Shapiro–Wilk’s test for non-normality, Statistics & Computing (2), 117–119
Royston, J P, 1995, A remark on AS R94: A remark on Algorithm AS 181: the test for normality, Appl. Statist. (44(4)), 547–551