PhysSandbox
Classical MechanicsWaves & SoundElectricity & MagnetismOptics & LightGravity & OrbitsLabsLessons
🌙Astronomy & The Sky🌡️Thermodynamics🌍Biophysics, Fluids & Geoscience📐Math Visualization🔧Engineering🧪Chemistry📊Statistics & Probability
ENRUESPTFRDE

Related simulators

Continue with similar topics in this category — or all 10 in Statistics & Probability.

View category →
NewKids

Law of Large Numbers

Launch Simulator

Coin or die: running mean x̄ₙ for several runs converges to μ; the ±σ/√n envelope shows how slowly.

NewFeaturedKids

Galton Board (Bean Machine)

Launch Simulator

Balls bounce left/right through rows of pegs; the bins fill a binomial that turns into a bell curve. Few rows vs many rows.

NewFeaturedKids

Central Limit Theorem

Launch Simulator

Pick a parent (uniform, exponential, binomial, die), draw samples of size n = 1, 5, 30; the histogram of means turns normal and its spread shrinks as σ/√n.

NewKids

Normal Distribution & z-Scores

Launch Simulator

Bell curve with μ and σ; shaded tails, the 68–95–99.7 rule, and a built-in z-score converter x → z = (x − μ)/σ.

NewKids

Pearson Correlation

Launch Simulator

Scatter cloud with adjustable r, covariance ellipse, and a parabola preset where r ≈ 0 despite a perfect relationship.

NewSchool

Confidence Interval Simulator

Launch Simulator

Draw a sample, build a 90/95/99 % interval for μ; repeat 100 times and count how many intervals catch the true mean.

PhysSandbox

Interactive physics, chemistry, and engineering simulators for students, teachers, and curious minds.

Physics

  • Classical Mechanics
  • Waves & Sound
  • Electricity & Magnetism

Science

  • Optics & Light
  • Gravity & Orbits
  • Astronomy & The Sky

More

  • Thermodynamics
  • Biophysics, Fluids & Geoscience
  • Math Visualization
  • Engineering
  • Chemistry
  • Statistics & Probability

© 2026 PhysSandbox. Free interactive science simulators.

PrivacyTermsContact
Home/Statistics & Probability/Binomial Distribution

Binomial Distribution

P(K = k) bars for n trials with success p; mean np, variance np(1−p); coin and rare-event presets; normal overlay at large n.

Binomial distribution

10
0.5

Highlight

5

Each experiment is n independent trials with the same success probability p; the count of successes K is binomial. The cyan bars are the exact pmf computed with log-gamma; the pink outlines are the relative frequencies of your experiments. Changing n or p clears the empirical histogram. The normal readout uses the continuity correction (k ± ½); Poisson(np) is only a good approximation when p is small and n is large.

Shortcuts

  • •Space / Enter — run 1 experiment
  • •R — reset the empirical histogram
  • •Drag the marker on the chart to move k

Measured values

Trials n10
Success probability p0.50
Mean np5.00
Variance np(1−p)2.500
Standard deviation1.581
P(K = 5) (exact)0.24609
Normal approx. (continuity corr.)0.24817
|exact − normal|0.00208
Experiments run0
Empirical mean of K—
Last experiment: successes—

About this model

The simulator models a fixed number n of independent trials, each succeeding with the same probability p, and counts the number of successes K. Under these two assumptions (independence and a constant p) K has the binomial distribution: P(K = k) = C(n, k) p^k (1 − p)^(n − k) for k = 0, 1, …, n, where C(n, k) = n! / (k!(n − k)!) is the number of orderings in which exactly k of the n trials succeed. The mean is E[K] = np and the variance is Var K = np(1 − p); the standard deviation is the square root of the variance. The cyan bars are this exact pmf. It is evaluated through the logarithm of the gamma function (a Lanczos approximation of ln Γ), so the bars are correct even for n = 200 where n! itself would overflow; cumulative probabilities P(K ≤ k) and P(K ≥ k) are sums of these terms in double precision, the upper tail being summed from the far end so that no cancellation occurs. The yellow curve is the normal density with the same mean and variance, N(np, np(1 − p)). Because the binomial is discrete and the normal is continuous, the normal approximation of a probability is read with the continuity correction: P(K ≤ k) ≈ Φ((k + ½ − np)/σ), P(K = k) ≈ Φ((k + ½ − np)/σ) − Φ((k − ½ − np)/σ), where Φ is the standard normal cdf computed from an erfc approximation accurate to about 1e-16. The readout shows the exact value, the normal value and their absolute difference, which is small when np(1 − p) is large (a common rule of thumb is np ≥ 10 and n(1 − p) ≥ 10). The green stems are the Poisson distribution with the same mean, Pois(np); it approximates the binomial well when n is large and p small, as in the rare-event preset (n = 100, p = 0.03), and poorly otherwise. The empirical layer draws n coins flipped by a seeded pseudo-random generator; the number of heads is one sample of K and is added to the pink outlined histogram of relative frequencies, which converges to the cyan bars as the number of experiments grows. Simplifications: trials are exactly independent with constant p; sampling without replacement (the hypergeometric case) is not modelled, and the coins only illustrate a generic Bernoulli trial. Related simulators on the site: statistics/galton-board, which builds the same distribution mechanically from left/right bounces; statistics/normal-distribution for the limiting curve; statistics/law-of-large-numbers for why the empirical mean settles at np; and statistics/p-value, where binomial tail probabilities appear as exact test p-values.

Who it's for: Upper secondary school (grades 10–12) probability units and introductory college statistics; no calculus required.

Key terms

  • Bernoulli trial
  • binomial coefficient C(n, k)
  • probability mass function
  • cumulative probability
  • expected value np
  • variance np(1 − p)
  • continuity correction
  • Poisson approximation

How it works

Repeat the same Bernoulli trial n times, independently and with the same success probability p; the number of successes K follows the binomial distribution with P(K = k) = C(n, k) pᵏ(1−p)ⁿ⁻ᵏ. Its mean is np and its variance np(1−p), so the bars are tallest near np and their relative spread shrinks like 1/√n. For large n the bars follow a normal curve N(np, np(1−p)); the continuity correction replaces the discrete k by the interval [k−½, k+½] when reading the normal approximation. When p is small and n large, K is close to Poisson(np). The flipped coins show one experiment; the pink outlines collect many experiments and approach the exact bars.

Key equations

P(K = k) = C(n, k) · pᵏ · (1 − p)ⁿ⁻ᵏ, k = 0 … n
E[K] = np, Var K = np(1 − p), SD = √(np(1 − p))
P(K ≤ k) ≈ Φ((k + ½ − np) / √(np(1 − p))) (continuity correction)
p small, n large: P(K = k) ≈ e^(−np) (np)ᵏ / k!

Frequently asked questions

Why is the bar for k = 5 the tallest for 10 coin flips, but still only about 25 %?
With n = 10 and p = 0.5 the mean is np = 5, so 5 heads is the single most likely count. There are C(10, 5) = 252 sequences with exactly five heads out of 2¹⁰ = 1024 equally likely sequences, giving P(K = 5) = 252/1024 ≈ 0.246. The remaining three quarters of the probability is spread over the other counts: 4 or 6 heads each have about 0.205, 3 or 7 about 0.117, and so on. 'Most likely' therefore does not mean 'likely'; the probability of landing within one standard deviation (√2.5 ≈ 1.58) of the mean, that is 4 ≤ K ≤ 6, is about 0.66.
What does the continuity correction do, and why is it needed?
The binomial variable takes only whole numbers, while a normal variable takes any real value. To approximate P(K ≤ k) with the normal curve, each integer k is represented by the interval from k − ½ to k + ½, so the whole event K ≤ k corresponds to the area under the curve up to k + ½, not up to k. Without the half the approximation systematically misses half a bar. For P(K = k) the corrected value is the area between k − ½ and k + ½, which is close to the height of the bar; with the correction the error for n = 20, p = 0.5 is below 0.001 at k = 10, while without it the normal gives P(K ≤ 10) ≈ 0.500 instead of the exact 0.588, an error of almost half a bar.
When is the Poisson approximation good, and when should I not use it?
The Poisson distribution with mean λ = np is the limit of the binomial as n grows and p shrinks with np held fixed. It is accurate when p is small, roughly p ≤ 0.05, and n is large enough that np is moderate; for n = 100, p = 0.03 the two distributions agree to within about 0.004 at every k. For p near 0.5 it is a poor approximation: the Poisson has variance λ = np, while the binomial has variance np(1 − p), which is only half as large at p = 0.5, so the Poisson stems are visibly too wide. The normal approximation is the right tool there.
After 1000 experiments the pink outlines still do not match the cyan bars exactly. Is something wrong?
No. Each pink bar is a relative frequency, a sample estimate of the corresponding exact probability, and it fluctuates from run to run. A bar whose true probability is q has standard error √(q(1 − q)/N) over N experiments; for q = 0.25 and N = 1000 that is about 0.014, so deviations of one or two hundredths are expected. As N increases the standard error shrinks like 1/√N: ten thousand experiments reduce it by a factor of about three, not ten. The same effect appears in the empirical mean, which approaches np but is not exactly np.