Skip to content

Instantly share code, notes, and snippets.

@michelkana
Last active June 30, 2021 16:01
Show Gist options
  • Save michelkana/1957c2ff7527b2706cd9c2a75dbf1e60 to your computer and use it in GitHub Desktop.
Save michelkana/1957c2ff7527b2706cd9c2a75dbf1e60 to your computer and use it in GitHub Desktop.
import math
import numpy as np
def f(n):
return math.factorial(n)
def mle(R, theta):
return (f(np.sum(R)) / (np.prod([f(r) for r in R]))) * \
np.prod([theta[i]**R[i] for i in range(len(R))])
# maximum likelihood
ml_A = mle(R_A,theta_A)
ml_B = mle(R_B,theta_B)
print("ML for Product A {:.7f}".format(ml_A))
print("ML for Product B {:.7f}".format(ml_B))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment