Skip to content

Instantly share code, notes, and snippets.

@steelcowboy
Last active January 16, 2016 23:01
Show Gist options
  • Save steelcowboy/a7d060fdb67336243d5c to your computer and use it in GitHub Desktop.
Save steelcowboy/a7d060fdb67336243d5c to your computer and use it in GitHub Desktop.
Calculator for binomial distributions
# By Jim Heald
import math
while True:
answer = 0
n = float(input('n: '))
p = float(input('p: '))
st = int(input('start: '))
end = int(input('end: '))
for x in range(st, end+1):
answer += (math.factorial(n)/(math.factorial(x) * math.factorial(n-x))) * p**x * (1-p)**(n-x)
print(answer)
input("Again? ")
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment