liveBook · Manning

Binomial experiment

As explained in Statistics Every Programmer Needs

A binomial experiment consists of a fixed number of independent trials, each having two possible outcomes with a constant probability of success.

A binomial experiment counts successes across a fixed number of repeatable trials. Each trial has two outcomes, success or failure, and the success probability remains constant. section 3.1.2

Model an experiment as binomial only when these conditions hold:

  • Use independent trials: one outcome neither changes nor is changed by another trial. section 3.1.2
  • Classify every trial as success or failure, with probabilities p and 1 − p. section 3.1.2
  • Fix the number of trials before the experiment begins. section 3.1.2
  • Keep the success probability constant, so the trials remain alike as well as independent. section 3.1.2

For n trials and k successes, the probability mass function combines the number of ways to choose the successes with p^k(1 − p)^(n − k). Compute the combination directly with factorials or use scipy.stats.binom.pmf.

Counting seven successes

With n = 20, k = 7, and p = 0.5, the calculated probability is 7.39288330078125%. Changing p to 0.2 produces 5.454985048652523% for the same n and k.

How Statistics Every Programmer Needs covers it

How deep it goes
Defines assumptions, explains the PMF, calculates coefficients, and implements probabilities in Python.
Examples
Uses coin flips, defective units, quality inspections, medical tests, surveys, and twenty-trial probability calculations.
What you can do after
Apply it via SciPy or direct factorial calculations to estimate probabilities for specified success counts.
How it connects
Connects discrete random variables with probability distributions and probability mass functions.

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.