Skip to content

Instantly share code, notes, and snippets.

@vlavorini
Last active January 10, 2019 16:29
Show Gist options
  • Save vlavorini/0aba57c72f0b1492e67044ac74698177 to your computer and use it in GitHub Desktop.
Save vlavorini/0aba57c72f0b1492e67044ac74698177 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
def calc_beta_mode(a, b):
'''this function calculate the mode (peak) of the Beta distribution'''
return (a-1)/(a+b-2)
def plot(betas, names, linf=0, lsup=0.01):
'''this function plots the Beta distribution'''
x=np.linspace(linf,lsup, 100)
for f, name in zip(betas,names) :
y=f.pdf(x) #this for calculate the value for the PDF at the specified x-points
y_mode=calc_beta_mode(f.args[0], f.args[1])
y_var=f.var() # the variance of the Beta distribution
plt.plot(x,y, label=f"{name} sample, conversion rate: {y_mode:0.1E} $\pm$ {y_var:0.1E}")
plt.yticks([])
plt.legend()
plt.show()
plot([beta_C, beta_T], names=["Control", "Test"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment