Last active
March 25, 2016 22:08
-
-
Save clbarnes/aaea2848e4a017d52b67 to your computer and use it in GitHub Desktop.
Get the alpha and beta parameters of the beta distribution from a mean and variance
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
| def get_beta_params(mu, var): | |
| """ | |
| From this answer http://stats.stackexchange.com/a/12239/101211 | |
| """ | |
| alpha = mu**2 * ( ((1-mu)/var) - 1/mu ) | |
| beta = alpha * (1/mu - 1) | |
| assert alpha > 0 and beta > 0 | |
| return alpha, beta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment