Skip to content

Instantly share code, notes, and snippets.

@tsutarou10
Last active August 22, 2017 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsutarou10/163dce714aebb6093bc8e65586caf82b to your computer and use it in GitHub Desktop.
Save tsutarou10/163dce714aebb6093bc8e65586caf82b to your computer and use it in GitHub Desktop.
ベータ分布
#coding: utf-8
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
from scipy.special import gamma
N = 100
alpha = [0.1,1.0,2.0,8.0,10.0]
beta = [0.1,1.0,3.0,4.0,10.0]
p = np.linspace(0.0,1.0, N)
print p
for a,b in zip(alpha,beta):
y = (gamma(a+b)/(gamma(a)*gamma(b))) * pow(p,a - 1) * pow(1-p,b - 1)
plt.plot(p,y,label = "a = " + str(a) + " b = " + str(b))
plt.legend(loc = "upper right")
plt.savefig("beta.png")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment