'betaABfromMeanSD' <- function(mean, sd)
{
if (mean <= 0 | mean >= 1) {
stop("must have 0 < mean < 1")
}
if (sd <= 0) {
stop("sd must be > 0")
}
kappa = mean*(1-mean)/sd^2 - 1
if (kappa <= 0) {
stop("invalid combination of mean and sd")
}
a = mean*kappa
b = (1.0-mean)*kappa
return(invisible(list(a = a, b = b)))
}
#EOF
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.