Skip to content

Instantly share code, notes, and snippets.

@dz0
Created March 9, 2020 12:02
Show Gist options
  • Select an option

  • Save dz0/ad38f796365b1b562f96c99e99c1fddf to your computer and use it in GitHub Desktop.

Select an option

Save dz0/ad38f796365b1b562f96c99e99c1fddf to your computer and use it in GitHub Desktop.
#%%
data = ...
#%%
import numpy
import scipy
values = []
for rand_state in range(1000):
mask = numpy.random.rand(len(data)) < 0.5
test = scipy.stats.ttest_ind(data[mask], data[~mask], equal_var=False)
values.append(test.pvalue)
#%%
# https://machinelearningmastery.com/a-gentle-introduction-to-normality-tests-in-python/
from matplotlib import pyplot as plt
plt.hist(values); plt.show()
plt.hist(data, bins=1000); plt.show()
from statsmodels.graphics.gofplots import qqplot
qqplot(data, line='s'); plt.show()
#%%
from scipy.stats import norm
from scipy.stats import shapiro
test = shapiro(data)
print("Shapiro", test)
from scipy.stats import normaltest # D’Agostino’s K^2 Test
test = normaltest(data)
print(test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment