Beta Distribution Calculator

JJ Ben-Joseph headshot JJ Ben-Joseph

Introduction to modelling proportions with the beta distribution

This beta distribution calculator evaluates a probability model that lives entirely on the unit interval from 0 to 1. That restricted support is exactly why the beta family appears so often in applied work: a very large share of the quantities people actually estimate are proportions, rates, or probabilities. A click-through rate, a manufacturing defect fraction, a one-year survival probability, a vaccine uptake share, and a checkout conversion rate are all confined to the interval between 0 and 1 by definition. With only two positive shape parameters, written here as a and b, the beta family can describe uncertainty that is flat, tightly concentrated near the middle, strongly skewed toward one end, or piled up against both boundaries at once.

The distribution is defined for a > 0 and b > 0 only. Those inequalities are strict: at a = 0 or b = 0 the defining integral diverges and no normalising constant exists, so a value of zero or a negative value is not a degenerate special case but an input the calculator has to reject outright. This page rejects such input with a specific message rather than returning a plausible-looking number.

On this page you enter a, b and an evaluation point x in [0, 1]. The calculator reports the density at x, the cumulative probability P(X ≤ x) and its complement P(X > x), the mean, variance, standard deviation, skewness and median, the mode with an explicit statement of which mode case applies, and a 2.5th to 97.5th percentile interval. It also draws the density curve with the area up to x shaded, so the number and the picture can be checked against each other. If you supply binomial data it additionally forms the conjugate posterior.

The intuition worth carrying away is that a acts as a pseudo-count of successes and b as a pseudo-count of failures. Raising a relative to b pulls probability mass toward 1; raising b relative to a pulls it toward 0; and raising the total a + b while holding the ratio fixed keeps the centre roughly where it was but squeezes the curve, which is the formal way of saying that more evidence produces more certainty. When either parameter falls below 1 the density diverges at the corresponding endpoint. That divergence is genuine mathematics rather than a numerical failure, because the singularity is integrable and the total area is still exactly 1.

How to use this beta distribution calculator on real data

Enter a and b as strictly positive numbers and x as a proportion between 0 and 1 inclusive, then press Compute. Percentages must be converted first: a threshold of 35% is entered as 0.35, never as 35. Decimal parameters such as a = 0.5 are perfectly legitimate; the shape parameters are real numbers, not counts, even though the Bayesian interpretation makes integer values common.

The two optional fields marked successes k and trials n switch on the Bayesian update. Leave them blank and the calculator simply describes Beta(a, b). Fill them in and it additionally reports the posterior Beta(a + k, b + n − k), its mean, and a 95% equal-tailed credible interval, while the chart overlays the posterior on the prior so the shift caused by the data is visible at a glance. Both k and n must be non-negative whole numbers with k ≤ n; anything else is refused rather than silently rounded.

After a successful calculation the Copy summary, Download CSV and Copy link buttons become available. The link encodes every input in the query string, so a colleague opening it sees precisely the same scenario, and the page restores those inputs and recalculates automatically on load. Reset clears the form, the chart and the result panel back to their initial state.

Formula reference: density, incomplete beta CDF, and moments

For a > 0, b > 0 and 0 ≤ x ≤ 1, the NIST/SEMATECH e-Handbook gives the standard beta density in the form below. The two power terms tilt mass toward one boundary or the other, and the beta function in the denominator is the normalising constant that forces the total area to 1.

f(x;a,b) = xa-1 (1-x)b-1 B(a,b)

The normalising constant B(a,b) is the complete beta function, defined by the integral below and equal to a ratio of gamma functions.

B(a,b) = 01 ta-1 (1-t)b-1 dt

Evaluating that ratio of gamma functions directly is the trap that breaks most browser implementations. Double precision overflows at Γ(171.62), so Γ(500) becomes infinity and the quotient ·/ becomes NaN. This calculator therefore never forms B(a, b) itself. It works in logarithms throughout, using a Lanczos approximation to the log-gamma function, and exponentiates once at the end.

lnB(a,b) = lnΓ(a) + lnΓ(b) - lnΓ(a+b)

The density is then recovered as f(x)=exp[(a-1)lnx+(b-1)ln(1-x)-lnB(a,b)], which stays finite for parameters in the hundreds of thousands.

The cumulative distribution function is the regularised incomplete beta function. It measures accumulated probability from 0 up to the chosen point, so it answers the question of how likely the random variable is to fall at or below that threshold.

F(x;a,b) = Ix(a,b) = 0x ta-1 (1-t)b-1 dt B(a,b)

That integral has no elementary closed form for general parameters, so it must be evaluated numerically. Naive Simpson or trapezoid quadrature over [0, x] is a poor choice, because whenever a < 1 the integrand is unbounded at the lower limit and any fixed grid produces wildly wrong answers. This page instead uses the continued fraction of DLMF equation 8.17.22, evaluated with the modified Lentz algorithm described in Numerical Recipes, together with the reflection identity below, which guarantees the fraction is only ever used in its rapidly converging regime.

Ix(a,b) = 1- I1-x (b,a)

The switch is made when xa+1a+b+2, the threshold recommended by the DLMF. Two exact special cases make excellent tests of any implementation: Beta(1, 1) is Uniform(0, 1), so its CDF must return F(x) = x exactly, and Beta(0.5, 0.5) is the arcsine distribution, whose CDF is written below. This page reproduces both to roughly fourteen significant figures.

Ix(12,12) = 2π arcsin(x)

The mean and variance describe the centre and spread of the distribution. These two formulas are usually the quickest way to sanity-check a parameter choice before looking at the full curve.

E[X] = aa+b Var(X) = ab a+b2 (a+b+1)

The NIST/SEMATECH e-Handbook states the mode formula with an explicit side condition, a > 1 and b > 1, and that condition is not decoration.

mode= a-1a+b-2  for  a>1, b>1

Applied outside that range the formula produces nonsense: at a = b = 0.5 it returns (−0.5)/(−1) = 0.5, which is the point of minimum density for a U-shaped arcsine curve, not its maximum. A calculator that prints the interior formula unconditionally is therefore reporting the exact opposite of the truth for boundary-heavy parameters. This page classifies the case instead: two modes at 0 and 1 when both parameters are below 1, a single boundary mode when exactly one is at or below 1, every point a mode when a = b = 1, and the interior formula only when it genuinely applies.

Skewness completes the shape description and shows directly that the sign of b − a controls which tail is longer.

γ1 = 2(b-a) a+b+1 (a+b+2) ab

Finally, the property that brings most visitors here is conjugacy. If the prior for an unknown success probability is Beta(a, b) and the data are k successes in n independent Bernoulli trials, the posterior stays in the beta family with updated parameters.

p(θk,n) = Beta(a+k,b+n-k)

Reading the output: densities, tail probabilities, and credible intervals

The three required inputs each play a different role. The value a is the first shape parameter, b is the second, and x is the location at which the model is evaluated. The point x must lie between 0 and 1 inclusive because the beta distribution has no support outside that interval; entering 1.4 is not a mild extrapolation but a query about a region where the density is identically zero, and the calculator says so rather than returning a number.

The returned PDF is a density, not a direct probability. That distinction matters because densities can be greater than 1 without violating any rule. A tall PDF simply means probability is packed tightly around that point. Actual probabilities come from areas under the curve. By contrast, the CDF is a true probability, so it always falls between 0 and 1. If you ask for the CDF at x = 0.4, you are asking for the probability that the random variable is at most 0.4.

The mean summarises the average location, the variance and standard deviation summarise the spread, and the mode identifies the most likely value when such a point exists. The median and the 2.5th and 97.5th percentiles are obtained by inverting the CDF with a bisection search, which is why they are reported to six decimal places rather than through the crude approximation (a − 1/3)/(a + b − 2/3) that is sometimes quoted. For two beta distributions with the same mean, the one with the larger a + b is the more concentrated and therefore represents the stronger evidence.

A few parameter patterns are worth memorising. a = b = 1 gives the uniform distribution. a > b leans the curve toward 1 and produces negative skewness; a < b leans it toward 0 and produces positive skewness. Both parameters greater than 1 and roughly equal gives a smooth central hump. Both below 1 gives a U shape with mass piled against both boundaries. Exactly one below 1 gives a monotone density. These five regimes cover essentially every beta curve you will meet.

The table below is a useful mental check, and every entry is reproducible with this calculator. Notice that the mean depends only on a/(a + b) while the variance falls as the total a + b grows, and that the mode column changes character rather than merely changing value once a parameter drops to 1 or below.

Selected Beta(a, b) parameter sets with their mean, variance, mode case and skewness
a b Typical shape Mean Variance Mode Skewness
1 1 Uniform on [0, 1] 0.5 0.083333 Every point 0
2 5 Skewed toward 0 0.285714 0.025510 0.2 0.596285
5 2 Skewed toward 1 0.714286 0.025510 0.8 −0.596285
2 2 Symmetric, single hump 0.5 0.05 0.5 0
0.5 0.5 Arcsine, U-shaped 0.5 0.125 0 and 1 0
500 500 Very tight around 0.5 0.5 0.000250 0.5 0

One practical reminder: an extremely large density near 0 or 1 can be perfectly valid. Beta densities diverge at a boundary whenever the corresponding shape parameter is below 1, and the model remains a proper distribution because the singularity is integrable. When that happens the calculator prints an explicit infinite-density note rather than a misleading finite number, and the CDF beside it is still exact.

Worked example: a Beta(2, 5) prior evaluated at x = 0.4

Suppose a quality team believes a new supplier's defect rate is probably low but is far from certain about it, and encodes that belief as Beta(2, 5). Because a < b the curve is tilted toward small values, which matches the stated belief. The question is how much probability that prior places at or below a 40% defect rate, so enter a = 2, b = 5, x = 0.4.

Start with the moments, which need no numerical machinery. The mean is 2/(2 + 5) = 0.285714. The variance is (2 × 5)/(7² × 8) = 10/392 = 0.025510, so the standard deviation is 0.159719. The mode is available because both parameters exceed 1: (2 − 1)/(2 + 5 − 2) = 1/5 = 0.2. Skewness is 2(5 − 2)√8 / (9√10) = 0.596285, confirming the long right tail.

Next the density. Here B(2, 5) = Γ(2)Γ(5)/Γ(7) = (1 × 24)/720 = 1/30, so the density is 30 x (1 − x)⁴. At x = 0.4 that is 30 × 0.4 × 0.6⁴ = 30 × 0.4 × 0.1296 = 1.5552. Because the parameters are small integers this can be checked by hand, which makes it an ideal regression test: any implementation that returns something other than 1.555200 here has a broken gamma function.

Finally the CDF. When a and b are positive integers the regularised incomplete beta function collapses to a binomial sum with n = a + b − 1 = 6 trials, giving P(X ≤ 0.4) = Σ from j = 2 to 6 of C(6, j) 0.4^j 0.6^(6−j) = 0.766720. The calculator's continued fraction returns 0.766720 to every digit displayed, and the complementary tail is P(X > 0.4) = 0.233280. The 95% central interval runs from 0.043272 to 0.641235, and the median is 0.264450 — noticeably below the mean, exactly as positive skewness demands.

Now add data. Suppose 3 defects appear in 40 inspected units. Entering k = 3 and n = 40 gives the posterior Beta(2 + 3, 5 + 40 − 3) = Beta(5, 42), with posterior mean 5/47 = 0.106383 and a 95% credible interval of 0.036248 to 0.207917. The posterior probability that the defect rate still exceeds 40% has collapsed to about 2.3 × 10⁻⁶. That single number is far more decision-relevant than the point estimate alone, and it is the kind of statement the beta distribution exists to support.

Limitations, numerical accuracy, and assumptions behind these results

Every figure on this page assumes the quantity being modelled really is a single probability on [0, 1] and that, in the Bayesian mode, the trials are independent with a constant success probability. If your observations are clustered, correlated over time, or drawn from a mixture of subpopulations, the beta-binomial update still runs but the resulting credible interval will be too narrow. Overdispersed count data need a beta-binomial or hierarchical model rather than a single beta posterior.

The beta distribution also has no support outside the unit interval. A variable naturally bounded between L and U must be rescaled to (y − L)/(U − L) before it can be modelled here; the four-parameter beta described in the NIST e-Handbook is exactly that rescaling, with location L and scale U − L. This calculator implements the standard two-parameter form only.

On accuracy, the log-gamma approximation used here is the standard Lanczos series, accurate to roughly fifteen significant figures across the range that IEEE double precision can represent, and the continued fraction is iterated until successive convergents agree to within 3 × 10⁻¹⁶. Verified identities include Beta(1, 1) reproducing F(x) = x, Beta(0.5, 0.5) reproducing the arcsine CDF, the reflection identity holding for asymmetric parameters, and Beta(500, 500) returning a density of 25.225018 and a CDF of 0.5 at the midpoint rather than NaN. Beyond roughly a + b = 10⁸ the bisection used for quantiles runs out of double-precision resolution, and results in the far tails below about 10⁻¹⁵ should be treated as order-of-magnitude only.

Three mistakes account for most misreadings. Do not enter percentages directly; convert them to proportions first. Do not read a density above 1 as a probability above 100% — only the CDF column is a probability. And do not treat a reported boundary mode as an error: for a ≤ 1 or b ≤ 1 the density genuinely attains its maximum at an endpoint, and the interior formula simply does not apply.

If you are choosing prior parameters from a target mean m and a prior strength s expressed in pseudo-observations, set a = m·s and b = (1 − m)·s, which reproduces the mean exactly and gives a + b = s. A prior centred on 0.25 carrying the weight of 16 observations is therefore Beta(4, 12). Increasing s tightens the prior around the same centre, and the chart on this page makes the effect immediately visible.

Sources for the beta distribution formulas used here

Density, CDF, mean, variance, mode condition and skewness follow NIST/SEMATECH, e-Handbook of Statistical Methods, section 1.3.6.6.17 “Beta Distribution” (itl.nist.gov). The incomplete beta function, the reflection identity and the continued fraction of equation 8.17.22 with the convergence threshold (a + 1)/(a + b + 2) come from the NIST Digital Library of Mathematical Functions, section 8.17 (dlmf.nist.gov/8.17). The modified Lentz evaluation of that continued fraction follows W. H. Press, S. A. Teukolsky, W. T. Vetterling and B. P. Flannery, Numerical Recipes: The Art of Scientific Computing, 3rd edition, Cambridge University Press, sections 5.2 and 6.4. Distribution theory, moment formulas and the conjugacy result follow N. L. Johnson, S. Kotz and N. Balakrishnan, Continuous Univariate Distributions, volume 2, 2nd edition, chapter 25, Wiley, 1995.

Beta distribution questions people actually ask

Why does this calculator work with log-gamma instead of the beta function itself?

Because B(a, b) = Γ(a)Γ(b)/Γ(a+b) is built from gamma values that overflow double precision once a parameter passes roughly 171, so a direct evaluation collapses to NaN for something as ordinary as Beta(500, 500). This page instead computes log B(a, b) = lnΓ(a) + lnΓ(b) − lnΓ(a+b) with a Lanczos log-gamma approximation and exponentiates only at the very end, so Beta(500, 500) still returns a finite density of about 25.225 at x = 0.5 and a CDF of exactly 0.5 there.

How is the beta CDF actually computed on this page?

The beta CDF is the regularised incomplete beta function I(x; a, b). It is evaluated with the continued fraction of DLMF equation 8.17.22, driven by the modified Lentz algorithm published in Numerical Recipes, and the reflection identity that swaps the parameters and replaces x by 1 − x is applied whenever x reaches (a+1)/(a+b+2), so the fraction always converges in a few dozen terms rather than thousands.

When is the beta mode formula (a-1)/(a+b-2) actually valid?

Only when a > 1 and b > 1. If both parameters are below 1 the density is U-shaped and has two modes, one at 0 and one at 1. If exactly one parameter is at or below 1 the density is monotone and its maximum sits on a boundary, and Beta(1, 1) is uniform so every point of the interval is a mode. This calculator names whichever case applies instead of printing the interior formula unconditionally.

How do I update a beta prior with binomial success and failure counts?

The beta family is the conjugate prior for the binomial likelihood, so a Beta(a, b) prior combined with k successes in n trials gives the posterior Beta(a + k, b + n − k). Fill in the optional successes and trials fields and the calculator reports the posterior parameters, the posterior mean (a + k)/(a + b + n) and a 95 percent equal-tailed credible interval next to the prior results.

Is Beta(1, 1) really identical to a uniform distribution?

Yes. With a = b = 1 the density reduces to 1/B(1, 1) = 1 at every point of the interval and the CDF reduces to F(x) = x, which is exactly Uniform(0, 1). Beta(0.5, 0.5) is a second named special case, the arcsine distribution, whose CDF is (2/π)·arcsin(√x); both identities are used as regression tests for the numerical routines behind this page.

Related calculators

If you are exploring nearby concepts, you may also want the beta function calculator, the binomial distribution calculator, and the gamma distribution calculator.

Strictly positive real number. Values below 1 make the density diverge at x = 0.

Strictly positive real number. Values below 1 make the density diverge at x = 1.

A proportion, not a percentage: enter 35% as 0.35. This is where the density is read off and the upper limit of the CDF.

Whole number of successes. Leave blank to describe the prior only.

Whole number of Bernoulli trials. With k this yields the posterior Beta(a + k, b + n − k).

Enter a, b and x, then press Compute for the density, CDF, moments, quantiles and an optional posterior.

Ready.

  • Prior density f(x; a, b)
  • Shaded area = P(X ≤ x)
  • Mean
  • Posterior density (when k and n are given)
The chart appears after you press Compute. The vertical axis is probability density, so the shaded region is a genuine probability and the full area under each curve integrates to 1.

No chart drawn yet.

Mini-game: Match the beta curve

This optional arcade-style mini-game is separate from the calculator result above. It turns the same ideas into a quick shape-matching challenge: you tune a and b to make your curve overlap the glowing target beta distribution before the timer runs out. It is a fast way to build intuition for skew, concentration, and boundary-heavy beta shapes.

Score0
Time75.0s
Round1
Streak0
Match0%
Lock0%

Click to play: Match the beta curve

A glowing target beta curve appears on the unit interval. Your cyan curve starts elsewhere. Tap A−, A+, B−, and B+ or use the arrow keys to tune the shape until your match rises above the lock threshold. Hold it there for a moment to clear the round. Later waves introduce sharper peaks and boundary-heavy targets.

Best score: 0

Takeaway: when a grows relative to b, the mass shifts toward 1; when b grows relative to a, it shifts toward 0.

Current curve: a = 1.00, b = 1.00

Goal: overlap the glowing target. Increasing both parameters usually narrows the curve while the ratio between them controls the mean.

Embed this calculator

Copy and paste the HTML below to add the Beta Distribution Calculator – PDF, CDF, Mean, Variance & Mode to your website.