Skip to main content
v2026.11,858 entries · CC-BY 4.0

Beta Distribution Formula: PDF, Mean, Variance, and Worked Example

The beta distribution formula (pdf, mean, variance, mode) for proportions between 0 and 1, with a worked Beta(2, 5) example and Excel, R and Python snippets.

Written and maintained by CASRAI Editorial Board

Last updated

The beta distribution is a continuous probability distribution on the interval from 0 to 1, controlled by two positive shape parameters, α and β. It is the standard model for an unknown proportion or probability, such as a conversion rate, a sensitivity, or a success probability in a Bayesian analysis. This page gives the density formula with every symbol explained, a worked example computed by hand, a reading guide for the parameters, and short snippets for Excel, R and Python.

What is the beta distribution? A definition in one paragraph

A random variable X follows a beta distribution with shape parameters α > 0 and β > 0, written X ~ Beta(α, β), when its values lie between 0 and 1 and its density is proportional to xα−1(1−x)β−1. Because every value is between 0 and 1, it describes quantities that are themselves proportions or probabilities. The two parameters control where the density sits and how concentrated it is. The NIST/SEMATECH e-Handbook of Statistical Methods defines the same family with optional lower and upper bounds, so it can also describe a quantity bounded on any finite interval.

Beta distribution formula

For 0 ≤ x ≤ 1, the probability density function (pdf) is:

f(x; α, β) = xα−1 (1−x)β−1 / B(α, β)

The normalising constant is the beta function, B(α, β) = ∫01 tα−1(1−t)β−1 dt = Γ(α)Γ(β) / Γ(α+β). SciPy and the R documentation write the same density as Γ(α+β) / (Γ(α)Γ(β)) × xα−1(1−x)β−1. The symbols are:

  • x: the value at which the density is evaluated, between 0 and 1.
  • α (alpha): the first shape parameter, greater than 0. It is the exponent on x.
  • β (beta): the second shape parameter, greater than 0. It is the exponent on (1−x).
  • B(α, β): the beta function, a constant that makes the total area under the curve equal 1.
  • Γ: the gamma function. For a positive integer n, Γ(n) = (n−1)!.

The summary statistics follow directly from α and β:

  • Mean = α / (α + β)
  • Variance = αβ / [(α + β)2(α + β + 1)]; the standard deviation is its square root.
  • Mode = (α − 1) / (α + β − 2), valid only when α > 1 and β > 1.

Notation differs between sources

The NIST handbook calls the shape parameters p and q and uses a and b for the lower and upper bounds of the interval. SciPy calls the shapes a and b and uses loc and scale to move the interval to [loc, loc + scale]. R calls them shape1 and shape2. Excel calls them alpha and beta and uses A and B as optional bounds. In every case the first shape goes with x and the second with (1−x), so check which symbol a source means before copying a formula.

Worked example with the arithmetic shown

Take X ~ Beta(2, 5), so α = 2 and β = 5.

  1. Beta function. B(2, 5) = Γ(2)Γ(5) / Γ(7) = (1! × 4!) / 6! = (1 × 24) / 720 = 1/30.
  2. Density at x = 0.2. f(0.2) = 0.21 × 0.84 / (1/30) = 0.2 × 0.4096 × 30 = 2.4576.
  3. Mean. 2 / (2 + 5) = 2/7 ≈ 0.2857.
  4. Variance. (2 × 5) / [72 × 8] = 10 / 392 ≈ 0.02551, so the standard deviation is √0.02551 ≈ 0.1597.
  5. Mode. (2 − 1) / (2 + 5 − 2) = 1/5 = 0.2, which is why the density is highest near 0.2.
  6. Probability that X ≤ 0.5. For integer parameters the cumulative distribution function (CDF) equals the upper tail of a binomial with 6 trials: P(X ≤ 0.5) = Σj=26 C(6, j) 0.56 = (64 − 1 − 6) / 64 = 57/64 = 0.890625.

A point worth noticing: the density at 0.2 is 2.4576, which is larger than 1. A density is not a probability. Only the area under the curve over an interval is a probability, and the total area is 1.

Beta distribution examples

A common use is the Bayesian update of a proportion. If the prior belief about a success probability is Beta(2, 5) and a study then records 6 successes and 4 failures, the posterior is Beta(2 + 6, 5 + 4) = Beta(8, 9). Its mean is 8/17 ≈ 0.4706, its standard deviation is about 0.1176, and its mode is 7/15 ≈ 0.4667. The prior parameters act like counts of earlier successes and failures that are added to the observed counts. The same family is used for batch yields, completion rates, and the proportion of a sample with a given attribute. For summarising a posterior like this, see summarizing a posterior distribution, and for checking how much the prior matters see prior sensitivity analysis.

Interpretation: how the parameters shape the curve

Parameter values What the formula implies
α = β = 1 x0(1−x)0 = 1 and B(1, 1) = 1, so the density is flat: the uniform distribution on 0 to 1.
α = β The density is symmetric about 0.5 and the mean is 0.5.
α > β The mean α/(α+β) is above 0.5, so mass leans toward 1.
α < β The mean is below 0.5, so mass leans toward 0 (as in the Beta(2, 5) example).
α > 1 and β > 1 A single peak inside the interval, at the mode (α−1)/(α+β−2).
α < 1 or β < 1 The factor xα−1 or (1−x)β−1 grows without bound at that end, so the density rises toward 0 or 1 and has no interior mode formula.
Larger α + β Writing μ = α/(α+β), the variance equals μ(1−μ)/(α+β+1), so the distribution tightens as α + β grows.

Assumptions and common mistakes

  • The quantity must be a proportion. The support is 0 to 1. Percentages must be divided by 100 first, and counts or rates above 1 are not beta distributed.
  • Mixing up α and β. Swapping them reflects the curve around 0.5 and turns a mean of 0.29 into 0.71.
  • Using the mode formula when a shape is 1 or less. The formula (α−1)/(α+β−2) is only valid when both shapes exceed 1.
  • Reading the density as a probability. Values above 1 are normal, as the worked example shows.
  • Exact 0 or 1 in the data. A beta density does not assign positive probability to exactly 0 or exactly 1, so observed proportions at those values need a different model or a documented adjustment.
  • Confusing it with the gamma and binomial families. The beta function is defined through the gamma function (see the gamma distribution formula), and the beta is the conjugate companion of the binomial likelihood. For interval estimates of a single observed proportion, confidence intervals for a proportion compares the standard methods.

How to report it (APA example)

State the distribution, both parameters, and the summary values the reader needs, rounded consistently. An APA-style sentence might read:

The unknown response rate was given a Beta(2, 5) prior (M = .29, SD = .16). After observing 6 successes and 4 failures, the posterior was Beta(8, 9) (M = .47, SD = .12, 95% equal-tailed credible interval [.25, .70]).

Report the software and function used so the interval can be reproduced. For the spread measure used above, see standard deviation: formula and interpretation.

How to calculate it in Excel, R or Python

Excel

Excel’s BETA.DIST(x, alpha, beta, cumulative, [A], [B]) returns the pdf when cumulative is FALSE and the CDF when it is TRUE. A and B default to 0 and 1.

=BETA.DIST(0.2, 2, 5, FALSE)   → 2.4576
=BETA.DIST(0.5, 2, 5, TRUE)    → 0.890625

R

R provides dbeta(x, shape1, shape2), pbeta(q, shape1, shape2), qbeta(p, shape1, shape2) and rbeta(n, shape1, shape2).

dbeta(0.2, 2, 5)              # 2.4576
pbeta(0.5, 2, 5)              # 0.890625
qbeta(c(0.025, 0.975), 8, 9)  # 0.2465 0.7012  (posterior interval)
2 / (2 + 5)                   # mean 0.2857

Python

In SciPy, scipy.stats.beta takes the shapes a and b as positional arguments.

from scipy.stats import beta
beta.pdf(0.2, 2, 5)            # 2.4576
beta.cdf(0.5, 2, 5)            # 0.890625
beta.mean(2, 5), beta.var(2, 5)  # 0.2857..., 0.02551...
beta.ppf([0.025, 0.975], 8, 9)   # [0.2465, 0.7012]

Frequently asked questions

What is the beta distribution?

It is a continuous distribution on the interval 0 to 1 with density xα−1(1−x)β−1 / B(α, β), used to model an uncertain proportion or probability. Its mean is α/(α+β) and its variance is αβ/[(α+β)2(α+β+1)].

What are some beta distribution examples?

Examples include a prior or posterior for a success probability in a Bayesian analysis (Beta(2, 5) updated to Beta(8, 9) above), the uniform distribution as the special case Beta(1, 1), and any model of a rate that is bounded between 0 and 1. For a hierarchical use, see Bayesian hierarchical models.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Beta Distribution Formula: PDF, Mean, Variance, and Worked Example

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Ask CASRAI · Regulatory Radar

Research-admin question? Get an answer that links its sources.

An AI assistant specialized in research administration. Every answer links its sources to check before you act. 2 questions free, no account. $29/month after.

  • Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.
  • Every answer numbers its sources and links each one, so you can check the source yourself.