How can I calculate the $\alpha$ and $\beta$ parameters for a Beta distribution if I know the mean and variance that I want the distribution to have? Examples of an R command to do this would be most helpful.

  • 4
    Note that the betareg package in R uses an alternative parameterization (with the mean, $\mu=\alpha/\alpha+\beta$, & the precision, $\phi=\alpha+\beta$--and hence the variance is $\mu(1-\mu)/(1+\phi)$) which obviates the need for these calculations. – gung Jul 25 '12 at 15:48
up vote 79 down vote accepted

I set$$\mu=\frac{\alpha}{\alpha+\beta}$$and$$\sigma^2=\frac{\alpha\beta}{(\alpha+\beta)^2(\alpha+\beta+1)}$$and solved for $\alpha$ and $\beta$. My results show that$$\alpha=\left(\frac{1-\mu}{\sigma^2}-\frac{1}{\mu}\right)\mu^2$$and$$\beta=\alpha\left(\frac{1}{\mu}-1\right)$$

I've written up some R code to estimate the parameters of the Beta distribution from a given mean, mu, and variance, var:

estBetaParams <- function(mu, var) {
  alpha <- ((1 - mu) / var - 1 / mu) * mu ^ 2
  beta <- alpha * (1 / mu - 1)
  return(params = list(alpha = alpha, beta = beta))

There's been some confusion around the bounds of $\mu$ and $\sigma^2$ for any given Beta distribution, so let's make that clear here.

  1. $\mu=\frac{\alpha}{\alpha+\beta}\in\left(0, 1\right)$
  2. $\sigma^2=\frac{\alpha\beta}{\left(\alpha+\beta\right)^2\left(\alpha+\beta+1\right)}=\frac{\mu\left(1-\mu\right)}{\alpha+\beta+1}<\frac{\mu\left(1-\mu\right)}{1}=\mu\left(1-\mu\right)\in\left(0,0.5^2\right)$
  • Can one use it for generating beta distribution based on sample Mean and Variance = SD^2? I mean I want to check whether my sample (with Mean and SD^2) belongs to beta distribution with Mu=Mean and SD^2=Var). Is this a correct way? – stan Aug 19 '12 at 17:29
  • 1
    @stan This will give you the Beta distribution which has the same mean and variance as your data. It will not tell you how well the distribution fits the data. Try the Kolmogorov-Smirnov Test. – Max Aug 19 '12 at 20:19
  • 4
    When I call this function with estBetaParams(0.06657, 0.1) I get alpha=-0.025, beta=-0.35. How is this possible? – Amelio Vazquez-Reina May 7 '14 at 23:46
  • 2
    @danno - It's always the case that $\sigma^2\leq\mu\left(1-\mu\right)$. To see this, rewrite the variance as $\sigma^2=\frac{\mu\left(1-\mu\right)}{\alpha+\beta+1}$. Since $\alpha+\beta+1\geq1$, $\sigma^2\leq\mu\left(1-\mu\right)$. – Max Nov 4 '15 at 3:06
  • 1
    @AmelioVazquez-Reina If you give your original data I expect it will quickly be obvious why a beta distribution isn't suitable. – Glen_b Nov 4 '15 at 3:49

Here's a generic way to solve these types of problems, using Maple instead of R. This works for other distributions as well:

eq1 := mu = Mean(BetaDistribution(alpha, beta)):
eq2 := sigma^2 = Variance(BetaDistribution(alpha, beta)):
solve([eq1, eq2], [alpha, beta]);

which leads to the solution

$$ \begin{align*} \alpha &= - \frac{\mu (\sigma^2 + \mu^2 - \mu)}{\sigma^2} \\ \beta &= \frac{(\sigma^2 + \mu^2 - \mu) (\mu - 1)}{\sigma^2}. \end{align*} $$

This is equivalent to Max's solution.

In R, the beta distribution with parameters $\textbf{shape1} = a$ and $\textbf{shape2} = b$ has density

$f(x) = \frac{\Gamma(a+b)}{\Gamma(a) \Gamma(b)} x^{a-1}(1-x)^{b-1}$,

for $a > 0$, $b >0$, and $0 < x < 1$.

In R, you can compute it by

dbeta(x, shape1=a, shape2=b)

In that parametrisation, the mean is $E(X) = \frac{a}{a+b}$ and the variance is $V(X) = \frac{ab}{(a + b)^2 (a + b + 1)}$. So, you can now follow Nick Sabbe's answer.

Good work!


I find:

$a = \left( \frac{1 - \mu}{V} - \frac{1}{\mu} \right) \mu^2$,


$b = \left( \frac{1 - \mu}{V} - \frac{1}{\mu} \right) \mu (1 - \mu)$,

where $\mu=E(X)$ and $V=V(X)$.

  • I realise my answer is very similar to the others. Nonetheless, I believe it is always a good point to first check what parametrisation R uses.... – ocram Jun 22 '11 at 18:25

On Wikipedia for example, you can find the following formulas for mean and variance of a beta distribution given alpha and beta: $$ \mu=\frac{\alpha}{\alpha+\beta} $$ and $$ \sigma^2=\frac{\alpha\beta}{(\alpha+\beta)^2(\alpha+\beta+1)} $$ Inverting these ( fill out $\beta=\alpha(\frac{1}{\mu}-1)$ in the bottom equation) should give you the result you want (though it may take some work).

  • 1
    Wikipedia has a section on parameter estimation that lets you avoid too much work :) – rm999 Jun 22 '11 at 18:10

For a generalized Beta distribution defined on the interval $[a,b]$, you have the relations:


which can be inverted to give:




  • A user has attempted to leave the following comment: "there's an error somewhere here. Current formulation does not return the correct variance." – Silverfish Apr 12 '15 at 15:14

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.