Skip to content

Instantly share code, notes, and snippets.

@lylayang
Created October 2, 2019 09:02
Show Gist options
  • Save lylayang/6abd6e4fac9b5097772aa75b0d79acaa to your computer and use it in GitHub Desktop.
Save lylayang/6abd6e4fac9b5097772aa75b0d79acaa to your computer and use it in GitHub Desktop.
import scipy.stats as stats
from scipy.stats import chi2
ob_table = np.array([[4514, 486], [4473, 527]])
result = stats.chi2_contingency(ob_table, correction = False) # correction = False due to df=1
chisq, pvalue = result[:2]
print('chisq = {}, pvalue = {}'.format(chisq, pvalue))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment