Created
May 2, 2011 14:36
-
-
Save bayerj/951687 to your computer and use it in GitHub Desktop.
Plotting the beta distribution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 16 must have *Z instead of /Z.