So, if I have a beta distribution with parameters a and b, Wikipedia says I can get the mean and variance like this:

mean = a / (a + b)
variance = a*b / ((a + b)^2 * (a + b + 1))

But I have the mean and variance, and I want to know a and b. This requires math. I was about to do math, but I decided to see if wolfram alpha was up to the task. And lo — though it sometimes ran into a "too much computation time" error — here is its result:

a = -mean * (mean^2 - mean + variance) / variance
b = a * (1/mean - 1)

No comments:

Post a Comment