Contents/ Part IX · Probability & Distributions Case Studies/ Chapter 50

Manufacturing Defects: the Binomial

Each batch holds 50 parts, and each part passes or fails inspection. The number of defects per batch is the binomial distribution, n independent Bernoulli trials counted up. From 1,000 inspected batches we estimate the defect rate, fit the model, and size the risk of a bad batch.

⏱️ ~12 min read
🐍 Notebook included
📊 Chapter 50

The E-commerce Conversions (Bernoulli) case study modeled one part with the Bernoulli. Stack 50 of them into a batch and count the defects, and you have the binomial, the most important discrete distribution in quality control. It turns a per-part defect rate into a full forecast of batch outcomes.

C
The binomial counts the successes in n independent Bernoulli trials. Its PMF is C(n, k) pk(1 − p)n−k, with mean np and variance np(1 − p). Here n = 50 parts and p is the defect rate.
🏭
The dataset

manufacturing_qc_inspections.csv records 1,000 inspections, each a batch of batch_size = 50 with a defective_count. We treat each batch as 50 Bernoulli trials and model the count of defects.

1

From the Part Rate to the Batch Count

The per-part defect rate is total defects over total parts: p = 0.0385. That single rate, plugged into the binomial, predicts the whole distribution of defects per batch, mean np = 1.93, variance np(1−p) = 1.85, both matching the data exactly.

Defects per batch: Binomial(50, 0.0385) fits the data 0123 456 defects per batch (mean np = 1.93)

The term C(50, k) counts the ways k defects can land among 50 parts, the combinatorics of Counting & Combinatorics made concrete. Multiply by the probability of any one such arrangement, pk(1−p)50−k, and the binomial PMF drops right onto the observed batches.

2

The Risk of a Bad Batch

Quality rules are thresholds, and the CDF P(X ≤ k) prices them. Reading it off the model tells the plant exactly how much production a given accept/reject rule will scrap.

RuleP(X ≤ k) acceptP(X > k) reject
at most 0 defects0.1400.860
at most 1 defect0.4210.579
at most 2 defects0.6970.303
at most 3 defects0.8740.126
at most 5 defects0.9880.012

A "reject if more than 2 defects" rule accepts 70% of batches, so it scraps about 30%, a costly bar. Loosening it to "more than 3" cuts scrap to 13%. The hand-computed P(X = 2) = C(50, 2) p²(1−p)⁴⁸ matches SciPy to four decimals, confirming the model is exactly the binomial.

3

Simulating a Production Run

Scale a single batch up to a full shift. The defect-free rate is P(X = 0) = (1−p)5014%, and a 30-batch day produces a total that is a sum of binomials, centered near 58 defects and, by the Central Limit Theorem, approximately normal.

🔢
The binomial is a sum of Bernoullis

Every binomial is just n Bernoulli trials added together, which is why np is the mean (n trials, each contributing p) and np(1−p) is the variance (n independent variances). Simulating 200,000 batches reproduces the mean 1.93 and the 14% defect-free rate, and a simulated day lets the plant budget rework from the distribution, not a guess.

🐍

Run the QC analysis

The companion notebook estimates the defect rate, overlays the fitted Binomial(50, 0.0385) on the observed batch counts, validates the fit with a chi-square goodness-of-fit test, tabulates the accept/reject CDF, confirms P(X = 2) by hand with C(50, 2), and simulates a production run, every figure reproduced in code.

📓 View Notebook (code & outputs) ▶ Open in Colab ⬇ View / Download on GitHub

View opens the rendered notebook instantly (no setup). Open in Colab runs & edits it live in your browser. To run locally, install numpy, pandas, scipy, and matplotlib and launch jupyter notebook.

🎓 Key Takeaways

  • Defects per fixed batch are binomial: n = 50 trials, defect rate p; PMF C(n, k) pk(1−p)n−k.
  • One rate p = 0.0385 gives mean np = 1.93 and variance np(1−p) = 1.85, both matching the data.
  • The CDF prices accept/reject rules: P(X ≤ 2) = 0.70, so a "more than 2" rule scraps 30% of batches.
  • C(50, k) counts the arrangements of k defects among 50 parts, combinatorics turning a part rate into a batch forecast.
  • A binomial is a sum of Bernoullis, and a day of batches is approximately normal by the CLT.
4

Quiz: Test Yourself

Eight quick questions on the binomial case study. Answer them, hit Check Answers, and keep refining until you score 100%. Your progress is saved, so you can hop back to the chapter and return anytime.