Foundations of Inference in Python
Paul Savala
Assistant Professor of Mathematics
new_satisfaction = [94, 85, 79, 91, 82] old_satisfcation = [90, 87, 77, 85, 82]
# Group together our data data = (new_satisfaction, old_satisfcation)
# Define our test statistic def statistic(x, y): return np.mean(x) - np.mean(y)
# Compute a permutation test for the difference in means stats.permutation_test(data, statistic, n_resamples=1000, vectorized=False, alternative='greater')
stats.pearsonr(red_data, blue_data)[0]
0.08
data = (red_data, blue_data)
def statistic(x, y): return stats.pearsonr(x, y)[0]
res = stats.permutation_test(data, statistic, n_resamples=1000, vectorized=False, alternative='two-sided')
print(res.pvalue < 0.05)
False
Foundations of Inference in Python