EZ Statistics

Beta Distribution Calculator

Calculator

Parameters

Distribution Chart

Click Calculate to view the distribution chart

Learn More

Beta Distribution: Definition, Formula, and Applications

Beta Distribution

Definition: The beta distribution is a family of continuous probability distributions defined on the interval [0, 1]. It is characterized by two positive shape parameters, α (alpha) and β (beta), which determine its shape and properties.

Formula:The probability density function (PDF) is given by:f(x;α,β)=Γ(α+β)Γ(α)Γ(β)xα1(1x)β1,0x1f(x; \alpha, \beta) = \frac{\Gamma(\alpha + \beta)}{\Gamma(\alpha)\Gamma(\beta)}x^{\alpha-1}(1-x)^{\beta-1}, \quad 0 \leq x \leq 1where:Γ(z)=0tz1etdt\Gamma(z) = \int_0^\infty t^{z-1} e^{-t} dt

Where:

  • α>0\alpha > 0 is the first shape parameter
  • β>0\beta > 0 is the second shape parameter
  • Γ(z)\Gamma(z) is the gamma function

Properties

Key Statistics:

  • Mean: E(X)=αα+βE(X) = \frac{\alpha}{\alpha + \beta}
  • Variance: Var(X)=αβ(α+β)2(α+β+1)\text{Var}(X) = \frac{\alpha\beta}{(\alpha + \beta)^2(\alpha + \beta + 1)}
  • Mode:
    • α1α+β2\frac{\alpha - 1}{\alpha + \beta - 2} for α,β>1\alpha, \beta > 1
    • 0 when α=1,β>1\alpha = 1, \beta > 1
    • 1 when α>1,β=1\alpha > 1, \beta = 1
    • Undefined when α,β<1\alpha, \beta < 1

Special Cases:

  • α=β=1\alpha = \beta = 1: Uniform distribution on [0,1]
  • α=β\alpha = \beta: Symmetric distribution around 0.5
  • α,β<1\alpha, \beta < 1: U-shaped distribution
  • α,β>1\alpha, \beta > 1: Unimodal distribution

Applications

1. Bayesian Statistics

The beta distribution is the conjugate prior for the Bernoulli, binomial, and geometric distributions. This makes it particularly useful in Bayesian inference for:

  • Estimating probabilities of success
  • Modeling conversion rates
  • A/B testing analysis

2. Project Management

Used in PERT (Program Evaluation and Review Technique) for:

  • Modeling task completion times
  • Risk assessment
  • Project duration estimation

3. Quality Control

Applied in manufacturing and quality control for:

  • Modeling proportions of defective items
  • Process capability analysis
  • Tolerance interval estimation

4. Market Research

Used in marketing analytics for:

  • Customer behavior modeling
  • Market share analysis
  • Customer lifetime value prediction

How to Calculate Beta Distribution in R?

R
1library(tidyverse)
2
3# Parameters
4alpha <- 2
5beta <- 5
6
7# Calculate probability between two values
8x1 <- 0.2
9x2 <- 0.6
10prob <- pbeta(x2, shape1 = alpha, shape2 = beta) - pbeta(x1, shape1 = alpha, shape2 = beta)
11print(str_glue("P({x1} < X < {x2}) = {round(prob, 4)}"))
12
13# Create plot
14x <- seq(0, 1, length.out = 1000)
15y <- dbeta(x, shape1 = alpha, shape2 = beta)
16df <- tibble(x = x, y = y)
17
18ggplot(df, aes(x = x, y = y)) +
19  geom_line(color = "blue") +
20  geom_area(data = subset(df, x >= x1 & x <= x2), 
21            aes(x = x, y = y), 
22            fill = "blue", 
23            alpha = 0.2) +
24  labs(title = str_glue("Beta Distribution (α = {alpha}, β = {beta})"),
25       x = "x",
26       y = "Probability Density",
27       caption = str_glue("P({x1} < X < {x2}) = {round(prob, 4)}")) +
28  theme_minimal() +
29  coord_cartesian(expand = FALSE)

How to Calculate Beta Distribution in Python?

Python
1import numpy as np
2import pandas as pd
3from scipy import stats
4import matplotlib.pyplot as plt
5import seaborn as sns
6
7# Set parameters
8alpha = 2  # shape parameter 1
9beta = 5   # shape parameter 2
10
11# Calculate probability between two values
12x1, x2 = 0.2, 0.6
13prob = stats.beta.cdf(x2, alpha, beta) - stats.beta.cdf(x1, alpha, beta)
14print(f"P({x1} < X < {x2}) = {prob:.4f}")
15
16# Create plot
17x = np.linspace(0, 1, 1000)
18pdf = stats.beta.pdf(x, alpha, beta)
19
20plt.figure(figsize=(10, 6))
21plt.plot(x, pdf, 'blue', label='PDF')
22
23# Add shaded area
24x_shade = x[(x >= x1) & (x <= x2)]
25pdf_shade = stats.beta.pdf(x_shade, alpha, beta)
26plt.fill_between(x_shade, pdf_shade, alpha=0.2, color='blue')
27
28# Customize plot
29plt.title(f'Beta Distribution (α = {alpha}, β = {beta})')
30plt.xlabel('x')
31plt.ylabel('Probability Density')
32plt.annotate(f'P({x1} < X < {x2}) = {prob:.4f}',
33            xy=(0.5, max(pdf)/2),
34            xytext=(0.5, max(pdf)/2))
35
36plt.grid(True, alpha=0.3)
37plt.show()

Related Links

Normal Distribution Calculator

Gamma Distribution Calculator

Student's t Distribution Calculator

F Distribution Calculator