Skip to content

Instantly share code, notes, and snippets.

@GermanCM
Created June 17, 2020 07:21
Show Gist options
  • Save GermanCM/73423c411370d18d3eb1f2554c9692ae to your computer and use it in GitHub Desktop.
Save GermanCM/73423c411370d18d3eb1f2554c9692ae to your computer and use it in GitHub Desktop.
Normality check Shapiro-Wilk test
from numpy.random import seed
from numpy.random import randn
from scipy.stats import shapiro
'''
24.5.2 Shapiro-Wilk Test
The Shapiro-Wilk test evaluates a data sample and quanti es how likely it is that the data
was drawn from a Gaussian distribution
'''
# normality test
stat, p = shapiro(sample_singles)
print('Statistics=%.3f, p=%.3f' % (stat, p))
# interpret
alpha = 0.05
if p > alpha:
print('Sample looks Gaussian (fail to reject H0)')
else:
print('Sample does not look Gaussian (reject H0)')
#source: https://machinelearningmastery.com/statistics_for_machine_learning/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment