# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.test.distribution.normality

## Class ShapiroWilk

• public class ShapiroWilk
extends HypothesisTest
The Shapiro-Wilk test tests the null hypothesis that a sample comes from a normally distributed population. The sample size must be between 3 and 5000.

The R equivalent function is shapiro.test.

• Patrick Royston, "A Remark on Algorithm AS 181: The W Test for Normality," Applied Statistics, 44, 547-551, 1995.
• Patrick Royston, "Approximating the Shapiro-Wilk W-test for non-normality," Statistics and Computing, Volume 2, Number 3, 117-119, 1992.
• Patrick Royston, "An Extension of Shapiro and Wilk's W Test for Normality to Large Samples," Applied Statistics, 31, 115-124, 1982d.
• Patrick Royston, "Algorithm AS 181: The W Test for Normality," Applied Statistics, 31, 176-180. 1982c.
• Patrick Royston, "An extension of Shapiro and Wilk's Wtest for normality to large samples," Appl. Statist., 31, 115-124, 1982b.
• Patrick Royston, "Algorithm AS177. Expected normal order statistics (exact and approximate)," Applied Statistics, 31, 161-165, 1982a.
• Wikipedia: Shapiro-Wilk test
• ### Constructor Summary

Constructors
Constructor and Description
ShapiroWilk(double[] sample)
Perform the Shapiro-Wilk test to test for the null hypothesis that a sample comes from a normally distributed population.
• ### Method Summary

All Methods
Modifier and Type Method and Description
String getAlternativeHypothesis()
Get the description of the alternative hypothesis.
String getNullHypothesis()
Get a description of the null hypothesis.
double pValue()
Get the p-value for the test statistics.
double statistics()
Get the test statistics.
• ### Methods inherited from class com.numericalmethod.suanshu.stats.test.HypothesisTest

isNullRejected, nGroups, nObs, oneSidedPvalue
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### ShapiroWilk

public ShapiroWilk(double[] sample)
Perform the Shapiro-Wilk test to test for the null hypothesis that a sample comes from a normally distributed population.
Parameters:
sample - a sample
• ### Method Detail

• #### getNullHypothesis

public String getNullHypothesis()
Description copied from class: HypothesisTest
Get a description of the null hypothesis.
Specified by:
getNullHypothesis in class HypothesisTest
Returns:
the null hypothesis description
Wikipedia: Null hypothesis
• #### getAlternativeHypothesis

public String getAlternativeHypothesis()
Description copied from class: HypothesisTest
Get the description of the alternative hypothesis.
Specified by:
getAlternativeHypothesis in class HypothesisTest
Returns:
the alternative hypothesis description
Wikipedia: Alternative hypothesis
• #### statistics

public double statistics()
Description copied from class: HypothesisTest
Get the test statistics.
Specified by:
statistics in class HypothesisTest
Returns:
the test statistics
Wikipedia: Test statistic
• #### pValue

public double pValue()
Description copied from class: HypothesisTest
Get the p-value for the test statistics.
Specified by:
pValue in class HypothesisTest
Returns:
the p-value