scipy hypothesis test for normal distribution

Solutions on MaxInterview for scipy hypothesis test for normal distribution by the best coders in the world

showing results for - "scipy hypothesis test for normal distribution"
Noah
21 Nov 2017
1>>> from scipy import stats
2>>> pts = 1000
3>>> np.random.seed(28041990)
4>>> a = np.random.normal(0, 1, size=pts)
5>>> b = np.random.normal(2, 1, size=pts)
6>>> x = np.concatenate((a, b))
7>>> k2, p = stats.normaltest(x)
8>>> alpha = 1e-3
9>>> print("p = {:g}".format(p))
10p = 3.27207e-11
11>>> if p < alpha:  # null hypothesis: x comes from a normal distribution
12...     print("The null hypothesis can be rejected")
13... else:
14...     print("The null hypothesis cannot be rejected")
15The null hypothesis can be rejected
16