Skip to content

Instantly share code, notes, and snippets.

@manashmandal
Last active May 23, 2017 02:48
Show Gist options
  • Save manashmandal/4895a19660ae8656e9538f63a3b4b5f9 to your computer and use it in GitHub Desktop.
Save manashmandal/4895a19660ae8656e9538f63a3b4b5f9 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
def likelihood(theta):
return theta**7 * (1 - theta)**3
thetas = np.linspace(0, 1, 100)
L = [likelihood(thetas[i]) for i in range(len(thetas))]
theta_for_maximum_likelihood = thetas[np.argmax(L)]
plt.plot(thetas, L)
plt.xlabel("Values of " + r"$\theta$")
plt.ylabel("Likelihood " + r"$L(y | k=7, n=10; \theta)$")
plt.xticks(list(plt.xticks()[0]) + [theta_for_maximum_likelihood])
plt.axvline(theta_for_maximum_likelihood)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment