Skip to content

Instantly share code, notes, and snippets.

@lundquist-ecology-lab
Last active January 14, 2023 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lundquist-ecology-lab/ae241c3b8975704b86651e8f63b34c58 to your computer and use it in GitHub Desktop.
Save lundquist-ecology-lab/ae241c3b8975704b86651e8f63b34c58 to your computer and use it in GitHub Desktop.
Binomial test in Python
# Binomial test in Python
from scipy.stats import binom_test
# Six-sided die flipped 24 times and lands on three exactly 6 times
x = binom_test(x=6, n=24, p=1/6, alternative='greater')
print(x)
# Flip coin 30 times and it lands on heads exactly 19 times
y = binom_test(x=19, n=30, p=1/2, alternative='greater')
print(y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment