Skip to content

Instantly share code, notes, and snippets.

@bayerj
Created May 2, 2011 14:36
Show Gist options
  • Select an option

  • Save bayerj/951687 to your computer and use it in GitHub Desktop.

Select an option

Save bayerj/951687 to your computer and use it in GitHub Desktop.
Plotting the beta distribution.
#!/usr/bin/env python
import sys
import scipy as sp
from scipy.special import gamma
import pylab
a = float(sys.argv[1])
b = float(sys.argv[2])
def pdf(a, b, x):
Z = gamma(a + b) / gamma(a) / gamma(b)
return x**(a - 1) * (1 - x)**(b - 1) / Z
x = sp.arange(0.0, 1.01, 0.01)
y = pdf(a, b, x)
ax = pylab.subplot(111)
ax.plot(x, y)
pylab.show()
@kei2e

kei2e commented Apr 29, 2020

Copy link
Copy Markdown

Line 16 must have *Z instead of /Z.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment