On 11/30/2005 10:14 AM, Scott Story wrote:
> I am trying to write a function that will solve a simple system of 
> nonlinear equations for the parameters that describe the beta 
> distribution (a,b) given the mean and variance.
> 
> 
> mean = a/(a+b)
> variance = (a*b)/(((a+b)^2) * (a+b+1))
> 
> Any help as to where to start would be welcome.

You should use a package like Maple or Mathematica (or just some pencil 
and paper work) to determine the solution.  Then the function is really 
easy to write.

Maple gives

 > solve({mean = a/(a+b),variance = (a*b)/(((a+b)^2) * (a+b+1))},{a,b});

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

from which you can write your own function pretty easily.

Duncan Murdoch

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to