Selecting the Top-Performing Sensor Calibration Batch
Statistics & ExperimentsModel answerLast updated
Design a statistically rigorous approach to rank five manufacturing batches using three binary pass/fail calibration checks per unit.
Sensor Calibration Batch Selection
A factory produces precision sensors. Before shipping, every sensor is run through three independent calibration checks. Each check produces a binary result: pass (1) or fail (0). Sensors were randomly assigned to one of five production batches at the start of the experiment, so batch membership is not self-selected.
You now have a full dataset with one row per sensor: its batch label and its three check outcomes.
Your task: Describe a statistically sound method to determine which batch has the best overall quality.
Your answer should cover all four of the following areas:
-
Composite metric. How do you collapse three binary check results into a single quality measure per batch? Discuss at least two options and the trade-offs between them. Identify the choice you would defend as the default and explain why.
-
Unequal batch sizes. Batches ended up with different numbers of sensors. Explain why this is manageable and how you handle it correctly.
-
Uncertainty quantification. How do you avoid crowning a winner that got lucky? Describe both a frequentist and a Bayesian way to attach uncertainty to each batch's quality estimate.
-
Multiple-comparison control. With five batches, naively picking the top one and testing it inflates your false-positive rate. Walk through a concrete strategy for controlling this, including what you would report when the evidence is inconclusive.
A strong answer is structured, uses precise terminology, mentions numbers where relevant (e.g., how many pairwise tests exist, typical threshold values), and acknowledges practical limitations.
Hints
Hint 1
Start by deciding what 'quality' means before touching the data. A sensor that passes two checks but fails the safety-critical one may still be unacceptable — your metric should reflect that business reality, not just an average.
Hint 2
Unequal group sizes only become a problem when you compare raw counts. Switching to rates with confidence intervals neutralizes the imbalance. Think about which interval formula behaves well near pass rates of 0.95 or higher.
Hint 3
With five groups you have ten possible pairwise comparisons. Running all of them at α = 0.05 gives you roughly a 40% chance of at least one false positive. A good answer names a specific correction strategy and explains when you would stop before even reaching the pairwise stage.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Framing the Problem
Random assignment is the foundation here. Because sensors were assigned to batches at random, any observed difference in pass rates is attributable to the batch rather than to pre-existing differences in the units. That license to read results causally is worth naming explicitly before diving into the statistics.
Step 1: Define a Composite Quality Metric
Each sensor i in batch g has outcomes Y₁, Y₂, Y₃ ∈ {0, 1}. You need to combine them. Choose your approach before looking at the data to avoid fishing.
Option A — All-pass indicator (recommended default)
Define Zᵢ = Y₁ · Y₂ · Y₃. A sensor is "good" only if it passes every check. This produces one Bernoulli trial per sensor, making inference clean and straightforward. The batch metric becomes p_g = P(Z = 1 | batch g). It also captures the business reality: a sensor that fails any check typically cannot ship.
Option B — Weighted score
Define Sᵢ = w₁Y₁ + w₂Y₂ + w₃Y₃, where weights reflect the severity of each check's failure mode (e.g., a safety-critical check should outweigh a cosmetic one). Weights must come from domain knowledge, not from the data itself — deriving weights from outcomes introduces circular reasoning.
Option C — Multivariate correlated model
Keep all three outcomes and fit a logistic mixed-effects model: logit P(Yᵢₖ = 1) = αₖ + β_g + uᵢ, where uᵢ is a per-sensor random effect that accounts for within-sensor correlation across checks. The group effect β_g becomes a single summary of batch quality across all three checks. This uses the most information but assumes the batch effect is consistent across checks — worth verifying with a batch × check interaction term.
Common mistake to avoid: naively averaging the three per-batch pass rates. This assumes the checks are independent, understates failure rates when they are correlated, and can hide a batch that is excellent on two checks but catastrophic on the safety-critical one. Also watch for survivorship bias: if sensors that fail check 1 are never sent to check 2, only the all-pass endpoint is cleanly defined for the full population.
Always report per-check pass rates as diagnostics alongside whichever composite metric you choose.
Step 2: Compare Batches with Unequal Sizes
For each batch, record n_g sensors and s_g all-pass sensors. The point estimate is p̂_g = s_g / n_g. Unequal batch sizes are not a bias problem — they are a precision problem. A smaller batch produces a wider confidence interval, nothing more.
Omnibus test first. Before any pairwise comparisons, ask whether the five batches differ at all. Run a chi-square test of homogeneity on the 5×2 contingency table (all-pass vs. at least-one-fail, by batch). With df = 4 and α = 0.05, a non-significant result is your stopping point — there is no evidence to name a winner. If expected cell counts fall below roughly 5, switch to Fisher's exact test. A logistic regression likelihood-ratio test (pass ~ batch vs. intercept only) is an equivalent, more extensible alternative.
Adjust for nuisance variables (production date, test station, operator shift) if you have them. Randomization removes confounding for the batch effect, but covariate adjustment reduces residual variance and tightens your estimates.
Step 3: Quantify Uncertainty
Frequentist — Wilson confidence intervals
Prefer the Wilson interval over the Wald interval (p̂ ± z√(p̂(1-p̂)/n)). The Wald interval breaks down near 0 or 1 — precisely where high-yield manufacturing operates. At 95% yield with n = 50, the Wald lower bound can dip below the true rate substantially, while Wilson stays well-calibrated.
For pairwise differences p_g − p_h, use Newcombe's hybrid interval or a bootstrap. A common mistake is concluding "no significant difference" because two individual 95% intervals overlap. Overlapping marginal intervals do not imply that the difference interval contains zero.
Bayesian — posterior probability of being best
Give each batch the conjugate posterior p_g | data ~ Beta(1 + s_g, 1 + n_g − s_g). Draw M = 200,000 samples from all five posteriors simultaneously and compute the fraction of draws in which batch g has the highest value. This directly answers the business question.
import numpy as np
def prob_best(s, n, draws=200_000, seed=42):
rng = np.random.default_rng(seed)
s, n = np.asarray(s), np.asarray(n)
# shape: (draws, 5)
samples = rng.beta(1 + s, 1 + n - s, size=(draws, len(s)))
best = samples.argmax(axis=1)
return np.bincount(best, minlength=len(s)) / draws
A hierarchical prior — where each p_g is drawn from a shared Beta(a, b) with a and b estimated from the data — adds partial pooling. Small batches get shrunk toward the global mean, guarding against a lucky small group appearing best by chance (winner's curse).
Step 4: Control for Multiple Comparisons
With five batches there are C(5,2) = 10 pairwise tests. Running all ten at α = 0.05 gives a family-wise error rate of up to ~40%. Selecting the top batch and testing only it against the others is also problematic: selection inflates the apparent advantage.
A practical strategy, in order:
- Gate on the omnibus test. If χ² is not significant, stop and report "no evidence of a difference." Proceed to pairwise testing only after rejection.
- Holm–Bonferroni on comparisons involving the top batch. Sort the four p-values from comparing the leading batch against each other batch. Reject the smallest if p₍₁₎ ≤ α/4, the next if p₍₂₎ ≤ α/3, and so on. This controls family-wise error while being less conservative than plain Bonferroni.
- All pairwise. Apply Holm across all 10 tests, or use Tukey-style contrasts on the logistic model. Use Benjamini–Hochberg (FDR control) only when the goal is screening rather than a final decision.
- Bayesian. Declare a winner if P(batch g is best) > 0.95. The joint posterior handles multiplicity through shrinkage without requiring explicit correction.
Report three possible outcomes, not just a winner:
- A single best batch (beats all others after adjustment).
- A tie set — e.g., "Batches 2 and 4 are indistinguishable and both outperform the rest."
- Insufficient evidence — the omnibus test did not reject, or no batch clears the post-correction threshold.
Step 5: Practical Significance
Statistical significance is not the same as business relevance. A 0.3-percentage-point gain in pass rate at 98% baseline yield may be significant with n = 10,000 but operationally meaningless. Report the absolute difference in pass rate and the defect-rate ratio alongside any p-value. If you have a minimum detectable effect in mind before running the study, confirm post-hoc that the sample sizes gave adequate power (typically 80%+) to detect that effect. If the study is already done and underpowered, name that as a limitation rather than concluding there is no difference.