# [R] Random Beta variates

Jari Oksanen jarioksa at sun3.oulu.fi
Mon Jun 17 08:23:39 CEST 2002

```Michael_Scroggie at nre.vic.gov.au said:
> I have been trying to use the rbeta() function to generate random beta
> variates with a particular mean and standard deviaiton  for some
> simulation problems I am working on, however I am unsure of the
> relationship between the parameters shape1 and shape2 and the mean and
> standard deviation of the beta distribution. I am guessing that there
> is a formula for this, but I am unsure what it is. Can anyone advise
> me?

This gives an excellent opportunity to find someone to check what I have done
earlier and correct my equations --- I had a similar problem, and then I worked
it out like this. First, the mean mu and variance sigma^2 expressed with alpha
and beta are:

mu = alpha/(alpha + beta)

sigma^2 = (alpha*beta)/[(alpha+beta)^2 * (alpha+beta+1)]

Then you need "only" solve these for alpha and beta. The following may be
correct:

alpha = mu*(mu^2-mu+sigma^2)/sigma^2

beta = (mu^2-mu+sigma^2)*(m-1)/sigma^2

cheers, jari oksanen
--
Jari Oksanen -- Dept Biology, Univ Oulu, 90014 Oulu, Finland
Ph. +358 8 5531526, cell +358 40 5136529, fax +358 8 5531061
email jari.oksanen at oulu.fi, homepage http://cc.oulu.fi/~jarioksa/

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```