StatsCalculators.com

Binomial Distribution

Created:August 11, 2024
Last Updated:April 13, 2025

This calculator helps you compute the probabilities of a binomial distribution. Simply enter the number of trials (n), the probability of success (p), and the desired comparison type and value. The calculator will display the probability distribution chart, as well as the mean and variance of the distribution.

Calculator

Parameters

Interactive Distribution Chart

Click Calculate to view the distribution chart

Learn More

Binomial Distribution

Definition: The binomial distribution is a discrete probability distribution that models the number of successes in a fixed number of independent Bernoulli trials. A Bernoulli trial is an experiment with two possible outcomes: success or failure.

Formula:P(X=k)=(nk)pk(1p)nkP(X = k) = \binom{n}{k} p^k (1-p)^{n-k}

Where:

  • nn is the number of trials
  • kk is the number of successes
  • pp is the probability of success on each trial
  • \inom{n}{k} is the binomial coefficient
Examples: Suppose you flip a fair coin 1010 times (n=10,p=0.5)(n = 10, p = 0.5). Let's calculate various probabilities:
  1. Probability of getting exactly 6 heads:P(X=6)=(106)(0.5)6(0.5)1060.2051P(X = 6) = \binom{10}{6} (0.5)^6 (0.5)^{10-6} \approx 0.2051
  2. Probability of getting between 3 and 7 heads (3<X<7)(3 < X < 7):P(3<X<7)=P(X=4)+P(X=5)+P(X=6)0.6563P(3 < X < 7) = P(X = 4) + P(X = 5) + P(X = 6) \approx 0.6563
  3. Probability of getting less than 5 heads (X<5)(X < 5):P(X<5)=P(X=0)+P(X=1)+P(X=2)+P(X=3)+P(X=4)0.3770P(X < 5) = P(X = 0) + P(X = 1) + P(X = 2) + P(X = 3) + P(X = 4) \approx 0.3770
  4. Probability of getting more than 4 heads (X>4)(X > 4):P(X>4)=1P(X4)0.6230P(X > 4) = 1 - P(X \leq 4) \approx 0.6230

Properties of Binomial Distribution

  • Mean: E(X)=npE(X) = np
  • Variance: Var(X)=np(1p)Var(X) = np(1-p)
  • Standard Deviation: SD(X)=np(1p)SD(X) = \sqrt{np(1 - p)}

Poisson Approximation to Binomial Distribution

When n is large and p is small, the binomial distribution can be approximated by a Poisson distribution with parameter λ = np:

  • Parameter: λ=np\lambda = np
  • Probability Mass Function: P(X=k)λkeλk!P(X = k) \approx \frac{\lambda^k e^{-\lambda}}{k!}

This approximation is generally considered good when n ≥ 20, p ≤ 0.1, and np ≤ 10.

Key Properties

  • Mean: E(X)=λ=npE(X) = \lambda = np
  • Variance: Var(X)=λ=npVar(X) = \lambda = np
  • The Poisson approximation simplifies calculations when dealing with rare events in large samples

Example: If you have n = 1000 trials with p = 0.005 probability of success, instead of using the binomial formula, you can approximate using Poisson with λ = 1000 × 0.005 = 5.

Normal Approximation to Binomial Distribution

When the sample size (n) is large, the binomial distribution can be approximated by a normal distribution with:

  • Mean: μ=np\mu = np
  • Standard Deviation: σ=np(1p)\sigma = \sqrt{np(1 - p)}

This approximation works well when both np5np \geq 5 and n(1p)5n(1-p) \geq 5.

Continuity Correction

When using the normal approximation for binomial probabilities, a continuity correction should be applied:

  • For P(X=k)P(X = k), use P(k0.5Xk+0.5)P(k-0.5 \leq X \leq k+0.5)
  • For P(Xk)P(X \leq k), use P(Xk+0.5)P(X \leq k+0.5)
  • For P(Xk)P(X \geq k), use P(Xk0.5)P(X \geq k-0.5)

The normal approximation is particularly useful for calculating binomial probabilities when n is large, as exact calculations become computationally intensive.

Interactive Normal Approximation Explorer

Adjust n (number of trials) and p (probability of success) to see when the binomial distribution approximates a normal distribution.

Mean (μ): 15.00

Standard Deviation (σ): 2.74

Approximation Conditions:

np ≥ 5:15.00
n(1-p) ≥ 5:15.00
✓ Normal approximation is valid

Key Observations:

  • For the normal approximation to be valid, both np ≥ 5 and n(1-p) ≥ 5 should be satisfied
  • As n increases, the binomial distribution becomes more bell-shaped
  • When p is close to 0 or 1, a larger n is needed for a good approximation
  • The normal approximation uses μ = np and σ = √(np(1-p))

How to Calculate Binomial Probabilities in R?

R
library(tidyverse)
n <- 10
p <- 0.5

# P(X = 6)
# dbinom(k, size, prob) returns the probability of getting k successes in n trials
prob_equal_6 <- dbinom(6, size = n, prob = p)
print(prob_equal_6) # 0.205078125

# P(X <= 4)
# pbinom(k, size, prob) returns the probability of getting at most k successes in n trials
prob_less_equal_4 <- pbinom(4, size = n, prob = p)
print(prob_less_equal_4) # 0.376953125

# P(X > 7)
# P(X > 7) = 1 - P(X <= 7)
prob_greater_7 <- 1 - pbinom(7, size = n, prob = p)
print(prob_greater_7) # 0.0546875

# P(3 < X < 8)
# P(3 < X < 8) = P(X <= 7) - P(X <= 3)
prob_between_3_and_8 <- pbinom(7, size = n, prob = p) - pbinom(3, size = n, prob = p)
print(prob_between_3_and_8) # 0.7734375

# mean and variance
print(str_glue("Mean: {n * p}")) # 5
print(str_glue("Variance: {n * p * (1 - p)}") # 2.5

How to Calculate Binomial Probabilities in Python?

Python
import scipy.stats as stats

n = 10
p = 0.5

# P(X = 6)
# stats.binom.pmf(k, n, p) returns the probability of getting k successes in n trials
prob_equal_6 = stats.binom.pmf(6, n, p)
print(prob_equal_6)

# P(X <= 4)
# stats.binom.cdf(k, n, p) returns the probability of getting at most k successes in n trials
prob_less_equal_4 = stats.binom.cdf(4, n, p)
print(prob_less_equal_4)

# P(X > 7)
prob_greater_7 = 1 - stats.binom.cdf(7, n, p)
print(prob_greater_7)

# P(3 < X < 8)
prob_between_3_and_8 = stats.binom.cdf(7, n, p) - stats.binom.cdf(3, n, p)
print(prob_between_3_and_8)

# mean and variance
print(f"Mean: {n * p}")
print(f"Variance: {n * p * (1 - p)}")

Related Calculators