MathsStatistics & Probability

Beta Distribution
calculator.

The beta distribution describes an unknown share or rate that falls between 0 and 1.

How it's worked out

Two positive shape numbers, α and β, set where the probability sits. The density on values from 0 to 1 is:

f(x)\displaystyle f(x)=xα−1(1−x)β−1B(α,β)\displaystyle {}= \frac{x^{\alpha - 1} (1 - x)^{\beta - 1}}{B(\alpha, \beta)}

B is the beta function, which scales the curve so its total area is 1. The chance of landing below x is the area up to x, and that area is the regularized incomplete beta function. The tool evaluates it with a continued fraction, and finds quantiles by narrowing in on the x that gives the chance you asked for.

F(x)\displaystyle F(x)=Ix(α,β)\displaystyle {}= I_x(\alpha, \beta)

The mean and variance have short forms. The mode exists as a single inside point only when both shapes are above 1.

mean\displaystyle \text{mean}=αα+β\displaystyle {}= \frac{\alpha}{\alpha + \beta}
variance\displaystyle \text{variance}=αβ(α+β)2(α+β+1)\displaystyle {}= \frac{\alpha \beta}{(\alpha + \beta)^2 (\alpha + \beta + 1)}
mode\displaystyle \text{mode}=α−1α+β−2\displaystyle {}= \frac{\alpha - 1}{\alpha + \beta - 2}

Updating with data

This is why the distribution is everywhere in Bayesian work. Start with Beta(α, β) for an unknown success rate, then see s successes and f failures, and the result is again a beta: Beta(α + s, β + f). Only the two shapes change, so no integral is needed. Beta(1, 1) is the flat starting point, since every value is then equally likely.

Where else it turns up

The kth smallest of n uniform random numbers follows Beta(k, n + 1 − k). That link is why the Clopper-Pearson interval for a proportion uses beta quantiles. Project planners use a stretched beta, the PERT distribution, to model a task between an optimistic and a pessimistic time.

Worked examples

Beta(2, 5), a curve leaning toward 0

Here B(2, 5) is one over 30, so the density at 0.3 is 30 × 0.3 × 0.7 to the fourth power, which is 2.1609. The chance of a value at or below 0.3 is 0.5798.

The binomial link checks that. With whole-number shapes, it is the chance of at least 2 successes in 6 trials with a 0.3 chance each, and that sum gives the same 0.5798. The mean is 0.2857, the mode is 0.2, and the chance of landing between 0.2 and 0.6 is 0.6144.

Open this example in the tool

A sign-up rate after 12 of 50 visitors convert

A landing page gets 12 sign-ups from 50 visitors. Starting flat at Beta(1, 1), you get Beta(13, 39), with a mean of 0.25. The middle 95% of it runs from 0.1433 to 0.3749.

The owner wants to know whether the true rate beats 20%. The area from 0.2 up to 1 is 0.7933, so that is likely on this prior, but it is not certain. The mean sits a little above the raw rate of 12 over 50, because the flat prior adds one success and one failure, which pulls it toward one half.

Open this example in the tool

The U-shaped Beta(0.5, 0.5)

This is the arcsine distribution, whose area below x has a closed form with the arcsine of the square root of x. At 0.25 that form gives exactly one third, and the tool gives 0.333333.

The curve piles up at both ends. The stretch from 0.1 to 0.9 covers 80% of the range, yet it holds only 0.5903 of the probability.

Open this example in the tool

Reading your result

Read the shape first. A larger α leans the curve toward 1, and a larger β leans it toward 0. A shape below 1 sends the density up without limit at that edge. Equal shapes give a symmetric curve.

Read α + β as confidence. Beta(20, 30) and Beta(2, 3) share a mean of 0.4, but their standard deviations are 0.069 and 0.2. The larger total behaves like a larger sample.

Keep density and probability apart. The density is the height of the curve, so it is not a probability, and it can pass 1. Beta(30, 30) reaches 6.15 at 0.5. Only areas are probabilities. When a shape is exactly 1, the density at that edge is finite and equals the other shape, as in Beta(1, 5), whose density at 0 is 5.

How the shapes change the center and spread
α, βMeanSDMode
1, 10.50.289None
2, 20.50.2240.5
2, 50.2860.160.2
5, 20.7140.160.8
0.5, 0.50.50.354None
10, 100.50.1090.5
1, 30.250.1940
The same shapes: skew and the middle 95%
α, βSkewnessMiddle 95%
1, 100.025 to 0.975
2, 200.094 to 0.906
2, 50.5960.043 to 0.641
5, 2−0.5960.359 to 0.957
0.5, 0.500.002 to 0.998
10, 1000.289 to 0.711
1, 30.8610.008 to 0.708

Shapes up to 1,000,000 are accepted. Past that, the curve is close to a spike, and a normal approximation is more practical.

Common mistakes

  • Reading the height as a chance. A density of 2 at some x does not mean a 200% chance. It means probability is packed tightly there.
  • Counting the prior twice. If you already fed the data into the shapes, leave the successes and failures at 0, or you add them again.
  • Assuming trials that do not hold. The update assumes independent trials with one fixed success rate. A rate that drifts over time breaks it, and the interval will look tighter than it should.
  • Mixing it up with the count distribution. For the chance of k successes when you know the rate, use the binomial distribution calculator. This tool is for what you believe about the rate itself.

Questions people ask

A density is probability per unit of x, not a probability. Only the total area has to equal 1, so a narrow curve must be tall. A density that rises to 6.15 over a slim range still has an area of 1.

Sources