Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

scipy check normal distribution

from scipy import stats
pts = 1000
np.random.seed(28041990)
a = np.random.normal(0, 1, size=pts)
b = np.random.normal(2, 1, size=pts)
x = np.concatenate((a, b))

k2, p_value = stats.normaltest(x)

alpha = 1e-3
print("p_value = {:g}".format(p))
# p_value = 3.27207e-11

if p_value < alpha:  # null hypothesis: x comes from a normal distribution
  print("The null hypothesis can be rejected")
else:
  print("The null hypothesis cannot be rejected")
# The null hypothesis can be rejected
Source by docs.scipy.org #
 
PREVIOUS NEXT
Tagged: #scipy #check #normal #distribution
ADD COMMENT
Topic
Name
1+4 =