liveBook · Manning

Binomial coefficient

As explained in Statistics Every Programmer Needs

A binomial coefficient is the number of ways to choose a specified number of items from a larger set without regard to order.

A binomial coefficient counts the ways to choose k successes from n trials when order does not matter. In a binomial probability mass function, it counts the arrangements that produce exactly k successes. section 3.1.2

Use the coefficient with the remaining binomial-PMF terms:

  • n is the total number of trials, k is the number of successes, and p is the probability of success on each trial. section 3.1.2
  • The probability of exactly k successes multiplies the coefficient by p^k and (1 − p)^(n − k). section 3.1.2
  • Compute it directly as n! divided by k!(n − k)!. section 3.1.2

Twenty trials, seven successes

With n = 20 and k = 7, the coefficient is 77,520. With p = 0.5, the resulting probability of exactly seven successes is 7.39288330078125%; with p = 0.2, it is 5.454985048652523%. section 3.1.2

>>> pmf = [(np.math.comb(n, j) * (p[i] ** j) * \
>>>         ((1 - p[i]) ** (n - j))) for j in k]

Apply the coefficient across possible success counts to calculate binomial PMF values in Python. section 3.1.2

How Statistics Every Programmer Needs covers it

How deep it goes
Defines the counting role, gives the factorial formula, and demonstrates direct and SciPy-based computation.
Examples
Uses twenty trials, seven successes, success probabilities of 0.5 and 0.2, and Python PMF calculations.
What it assumes
Assumes binary repeated trials while defining n, k, and p and introducing the PMF components.
What you can do after
Apply it via Python to calculate exact-success probabilities for chosen trial counts and success probabilities.
How it connects
Connects binomial distributions, probability mass functions, independent trials, and factorial computation.

Also explained in

Compare how 4 books explain binomial coefficient →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.