Skip to content

Instantly share code, notes, and snippets.

@suminb
Created October 24, 2012 09:18
Show Gist options
  • Save suminb/3945038 to your computer and use it in GitHub Desktop.
Save suminb/3945038 to your computer and use it in GitHub Desktop.
Binomial Likelihood Function
#
# Example from: http://warnercnr.colostate.edu/~gwhite/fw663/BinomialLikelihood.PDF
#
from math import factorial
# Number of flips
n = 11
# Number of heads
y = 7
# Binomial likelihood function
L = lambda p: C(n, y) * p**y * (1-p)**(n-y)
# Combinations
C = lambda n, y: factorial(n)/(factorial(y) * factorial(n-y))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment