liveBook · Manning

Binomial distribution

As explained in Math and Architectures of Deep Learning

A discrete probability distribution giving the chance of exactly k successes in n independent trials with constant success probability π.

The binomial distribution models the number of successes in n independent trials when every trial has the same success probability π. It turns aggregate success statistics into probabilities for count outcomes, a useful perspective when a system predicts chances rather than inspecting each observation directly. section 5.9.3 section 5.0

Build the probability from elementary trial outcomes:

  • A success has probability π, while a failure has probability 1 − π. section 5.9.3
  • For one particular sequence containing k successes and n − k failures, multiply the corresponding probabilities: π^k(1 − π)^(n − k). section 5.9.3
  • Because the k successes can occupy multiple positions, multiply by the number of such arrangements, C(n,k), giving P(X = k) = C(n,k)π^k(1 − π)^(n − k). section 5.9.3
  • The expected count is nπ and the variance is nπ(1 − π). section 5.9.3

Three celebrity-photo trials

If 20% of photos contain a celebrity, then π = 0.2. For three randomly selected photos, the probability of exactly two celebrity photos is 0.8 × 0.2 × 0.2 + 0.2 × 0.8 × 0.2 + 0.2 × 0.2 × 0.8 = 0.096. The three terms represent the possible positions of the single failure. section 5.9.3

Table 5.8 All possible combinations of three trials

Event Id

Event

Probability

0

{F, F, F}

(1−π) × (1−π) × (1−π) = 0.8 × 0.8 × 0.8

1

{F, F, S}

(1−π) × (1−π) × π = 0.8 × 0.8 × 0.2

2

{F, S, F}

(1−π) × π × (1−π) = 0.8 × 0.2 × 0.8

3

{F, S, S}

(1−π) × π × π = 0.8 × 0.2 × 0.2

4

{S, F, F}

π × (1−π) × (1−π) = 0.2 × 0.8 × 0.8

5

{S, F, S}

π × (1−π) × π = 0.2 × 0.8 × 0.2

6

{S, S, F}

π × π × (1−π) = 0.2 × 0.2 × 0.8

7

{S, S, S}

π × π × π = 0.2 × 0.2 × 0.2

Use the table to inspect all eight success–failure sequences for three trials and see how sequences with the same success count combine. section 5.9.3

PyTorch provides torch.distributions.Binomial. Its log_prob(X) can be checked against a direct implementation using factorial-based C(n,k), powers of π and 1 − π, and a logarithm. Sampling many values also checks the theoretical mean and variance. section 5.9.3

How Math and Architectures of Deep Learning covers it

How deep it goes
Derives the count probability from trial sequences, gives mean and variance, and verifies implementation numerically.
Examples
Uses celebrity-photo selection, an eight-row three-trial outcome table, PyTorch log probabilities, and sampled moments.
What it assumes
Assumes multiplication of independent event probabilities and introduces the count model from individual success and failure outcomes.
What you can do after
Apply it via PyTorch, calculate exact count probabilities, evaluate log probabilities, and compare sampled moments with theory.
How it connects
Connects independent trials, Bernoulli outcomes, probability distributions, and the multinomial distribution.

Also explained in

Compare how 6 books explain binomial distribution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math and Architectures of Deep Learning. The section links point to the parts of the book it draws on.