Created
March 9, 2020 12:02
-
-
Save dz0/ad38f796365b1b562f96c99e99c1fddf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #%% | |
| 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