Skip to content

Instantly share code, notes, and snippets.

@rtkilian
Created May 12, 2022 21:37
Show Gist options
  • Save rtkilian/30ece34d25c9d3de0f0de0c28b87a62c to your computer and use it in GitHub Desktop.
Save rtkilian/30ece34d25c9d3de0f0de0c28b87a62c to your computer and use it in GitHub Desktop.
# Example of the Analysis of Variance Test
from scipy.stats import f_oneway
# Randomly generate the data
x1 = rng.normal(loc=0.25, scale=1, size=100)
x2 = rng.normal(loc=0.00, scale=1, size=100)
x3 = rng.normal(loc=0.00, scale=1, size=100)
# Calculate test statistic and p-value
stat, p = f_oneway(x1, x2, x3)
# Interpreation
print('stat=%.3f, p=%.3f' % (stat, p))
if p > 0.05:
print('Do not reject the null hypothesis and conclude the means of the samples are the same.')
else:
print('Reject the null hypothesis and conclude that one or more of the means of the samples are not the same.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment