Skip to content

Instantly share code, notes, and snippets.

@niklasbuschmann
Last active November 23, 2020 18:53
Show Gist options
  • Save niklasbuschmann/44467229e6feddc37c90aa9876a106e5 to your computer and use it in GitHub Desktop.
Save niklasbuschmann/44467229e6feddc37c90aa9876a106e5 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import binom
from scipy.stats import norm
q = 100
NA = 100
NB = 60
qA = np.arange(0, q + 1, 1)
qB = np.arange(q, -1, -1)
OA = binom(3 * NA - 1 + qA, qA)
OB = binom(3 * NB - 1 + qB, qB)
sm = np.sum(OA * OB)
plt.bar(qA, OA * OB)
mean = np.sum(qA * OA * OB / sm)
variance = np.sum((qA - mean)**2 * OA * OB / sm)
plt.plot(sm * norm.pdf(qA, mean, np.sqrt(variance)), color = 'r')
plt.xlabel("qA")
plt.ylabel("Ω tot")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment