Created
May 12, 2022 21:42
-
-
Save rtkilian/34b4786938fba39f35c561d2063409df 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
from scipy.stats import chi2_contingency | |
# Example contingency table | |
table = [[100, 80, 70],[150, 20, 80]] | |
# Calculate test statistic and p-value | |
stat, p, dof, expected = chi2_contingency(table) | |
# Interpreation | |
print('stat=%.3f, p=%.3f' % (stat, p)) | |
if p > 0.05: | |
print('Do not reject the null hypothesis and conclude the variables are independent.') | |
else: | |
print('Reject the null hypothesis and conclude that the variables are dependent.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment