Shapiro Wilk test for normality - mauriceling/mauriceling.github.io GitHub Wiki

Purpose: To test whether the sample data is normally distributed.

Null hypothesis: Sample is drawn from a normally distributed population.

Alternate hypothesis: Sample is not drawn from a normally distributed population.

Code:

>>> from scipy import stats
>>> X = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
>>> result = stats.shapiro(X)
>>> print("Statistic = %.3f" % result[0])
Statistic = 0.960
>>> print("p-value = %.3f" % result[1])
p-value = 0.551

Reference

  1. Shapiro SS, Wilk MB. 1965. An analysis of variance test for normality (complete samples). Biometrika 52, 591-611.