Intuition

Imagine flipping a coin times and counting heads. More generally, any time you repeat a yes/no experiment a fixed number of times with the same success probability on each trial, the total number of successes follows a binomial distribution. It’s one of those distributions you reach for almost reflexively once you recognize the setup: fixed trials, two outcomes, independence, constant .

Definition

A random variable follows a binomial distribution if it represents the number of successes in independent Bernoulli trials, each with success probability and failure probability .

can take integer values .

Four conditions must hold for a binomial model to apply:

  1. The number of trials is fixed in advance.
  2. Each trial has exactly two outcomes (success or failure).
  3. Trials are mutually independent.
  4. The probability of success is constant across all trials.

Key Formulas

Probability Mass Function (PMF):

where is the binomial coefficient.

Mean:

Variance:

Standard Deviation:

The binomial coefficient counts the number of ways to choose which of the trials are successes.

Example

Four identical electronic components are subjected to a shock test. Each has a 75% chance of surviving (). What is the probability that exactly 2 survive?

So there is roughly a 21% chance that exactly 2 of the 4 components survive.

The expected number of survivors is , with variance .

We can also compute the probability that at least 3 survive:

So there is about a 74% chance that 3 or more components survive the test.

Why It Matters in CS

Anytime you’re counting “how many out of ” in a system, you’re probably looking at a binomial. Packet losses across transmissions, bit errors in a block of encoded data, defective chips on a wafer - all binomial if the trials are independent with constant .

The place you’ll encounter it most directly is A/B testing. When 5,000 users visit a page and 312 convert, that conversion count is . The entire statistical significance calculation rests on this model. Understanding the binomial also tells you why small-sample A/B tests are so unreliable: the variance is large relative to the mean when is small, so the observed conversion rate swings wildly between runs.

Tip

When is large and is moderate, computing directly overflows most integer types. In practice you’d use the normal approximation ( and ) or work in log-space.

Note: Probability Distributions covers the binomial at an overview level. This note provides a deeper treatment with worked examples and CS applications.