Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Part 2: The Binomial Distribution — Counting Successes

DhvaniAI

An Applied Scenario — One Second of Vibration Samples

Back to the motor from Part 1. The accelerometer streams 1,000 samples per second, and your threshold rule fires a 1 whenever a sample exceeds +2 g. On a healthy machine, calibration gave you p=0.005p = 0.005 (1 in 200 samples is a transient).

You decide to summarise the stream one second at a time: count how many 1s show up in each 1,000-sample window. That count is the alarm metric the operator sees.

A few obvious questions:

You already have all the ingredients. Each window is n=1000n = 1000 independent Bernoulli trials with p=0.005p = 0.005. The thing you’re counting — successes out of nn trials — has a name.


Intuition

If a Bernoulli trial is one coin flip, the Binomial distribution answers: “If I run nn independent trials, each with success probability pp, how many successes will I get?”

In every case the structure is identical: nn independent Bernoulli trials with the same pp, count the successes.


The Math

P(kn,p)=(nk)pk(1p)nkP(k \mid n, p) = \binom{n}{k} p^k (1-p)^{n-k}

where (nk)=n!k!(nk)!\binom{n}{k} = \frac{n!}{k!(n-k)!} is the number of ways to choose which kk out of nn trials succeed.

Mean: E[k]=npE[k] = np Variance: Var(k)=np(1p)\text{Var}(k) = np(1-p)

Breaking the formula down:


Back to the Vibration Sensor

For the motor scenario:

n=1000,p=0.005E[k]=5,Var(k)=4.975,σ2.23n = 1000, \quad p = 0.005 \quad\Rightarrow\quad E[k] = 5, \quad \text{Var}(k) = 4.975, \quad \sigma \approx 2.23

So on a healthy machine you should see about 5 crossings per second, and a typical fluctuation of ±2\pm 2 or so. A count of 7 is unremarkable. A count of 20 is roughly 7σ7\sigma above the mean — that’s not normal variation, that’s a state change worth investigating.

This is a real condition-monitoring rule built from one Bernoulli trial and one sum.


Visualizing the Binomial: Shape vs. nn and pp

The shape depends on both parameters.

For the motor case, p=0.005p = 0.005 and n=1000n = 1000 — extremely small pp, large nn. The distribution is heavily skewed and concentrated near small counts. That regime — many trials, each rare — is exactly where the Binomial morphs into the Poisson distribution (Part 3).


Simulation: Repeated Windows

Simulating many 1-second windows from the same machine is the empirical version of the formula. Each simulated window is one independent set of nn Bernoulli trials.

Why simulate when we have the formula? Simulation validates the theory and builds intuition. If simulation and formula disagree, one of them is wrong — a powerful debugging technique that survives all the way into deep learning, where closed-form answers stop existing and Monte Carlo is your only tool.

What to look for: the simulation histogram should hug the theoretical PMF. Small residual differences shrink as the number of simulated windows increases (also a CLT effect).


Where Else Binomial Counts Appear

DomainnnppCount kk
Vibration monitoringSamples per windowP(threshold crossing)Crossings per window
Quality controlUnits per batchP(defective unit)Defects per batch
A/B testingVisitors in a bucketP(conversion)Conversions per bucket
Image thresholdingPixels in a patchP(intensity > T)Bright pixels per patch
Photon countingIncident photonsQuantum efficiencyDetected electrons

The formula doesn’t care what the trial is — only that the trials are independent and share the same pp. When pp varies across trials or trials aren’t independent, you need a different model. We’ll handle that in later parts.