Why Engineers Should Care About A/B Testing
A/B testing (also called a controlled experiment or split test) is a method for comparing two versions of something — a website feature, a control algorithm, a material batch, a process setting — by randomly assigning subjects to one version or the other and measuring which performs better on a defined outcome. Though the term originated in web and product analytics, the underlying statistical framework is exactly the experimental design and hypothesis-testing methodology that has existed in engineering and science for a century, and it applies directly and usefully to comparing two control algorithms on a machine, two batches of raw material, or two settings of a manufacturing process. This article covers the statistical fundamentals — hypothesis testing, significance, sample size and power — and the pitfalls that most commonly invalidate an otherwise well-intentioned engineering experiment.
Hypothesis Testing Basics
Every A/B test starts with two competing hypotheses. The null hypothesis (H₀) states that there is no real difference between the two conditions being compared — any observed difference in the data is just random variation. The alternative hypothesis (H₁) states that there is a real difference. A hypothesis test does not directly prove either hypothesis true; instead, it asks: "If the null hypothesis were actually true (no real difference), how likely would it be to see a difference in our sample data at least as large as the one we observed, purely by chance?" That probability is the p-value.
A small p-value means the observed difference would be unlikely under the null hypothesis, giving grounds to reject the null hypothesis in favor of the alternative — but a p-value is not the probability that the null hypothesis is true, and it is not the probability that your result is a fluke; it is specifically the probability of seeing data this extreme (or more extreme) if the null hypothesis were true. This distinction is subtle but important, and getting it backward is one of the most common misinterpretations of statistics in applied work.
Statistical Significance
Before running a test, you choose a significance level, denoted α (alpha), typically set to 0.05 (5%). If the resulting p-value is below α, the result is called statistically significant — the observed difference is unlikely enough under the null hypothesis that you reject it and conclude a real difference likely exists. The α level is exactly the false-positive rate you are willing to accept: at α = 0.05, if you ran many experiments where no real difference actually existed, you would still expect to see a "significant" result about 5% of the time by pure chance. This is why a single significant result should be treated with appropriate caution, especially for a surprising or high-stakes finding, and why replication (or a sufficiently large, well-powered single test) matters.
Type I and Type II Errors
| H₀ actually true (no real difference) | H₀ actually false (real difference exists) | |
|---|---|---|
| Test says significant | Type I error (false positive) — rate = α | Correct detection |
| Test says not significant | Correct — no false alarm | Type II error (false negative) — rate = β |
A Type I error is concluding there is a real difference when there is not — acting on a false signal, such as switching to a new control algorithm that is not actually better. A Type II error is failing to detect a real difference that does exist — missing a genuine improvement because the test was not sensitive enough to catch it. Engineering decisions should weigh both error types against their real costs: switching a safety-critical process setting based on a false positive can be far more costly than a false negative that simply delays adopting a genuine improvement, so the acceptable α and β should reflect that asymmetry rather than defaulting blindly to 0.05/0.20.
Statistical Power and Sample Size
Statistical power is the probability that a test correctly detects a real effect of a given size, if one truly exists — formally, power = 1 − β. A commonly used target is 80% power, meaning that if a real effect of the size you specified exists, your test has an 80% chance of detecting it as statistically significant. Power depends on four interrelated factors: the significance level α, the effect size you want to be able to detect, the variability (noise) in your outcome measurement, and the sample size. Of these, sample size is usually the one you can control directly, which is why a sample size calculation — determining how many observations you need per group before starting — is a mandatory step in any properly designed engineering experiment, not an afterthought.
Worked example: Suppose you want to compare the defect rate of two material batches, with a current baseline defect rate of 8%. You decide the smallest improvement worth detecting is a drop to 5% (a 3-percentage-point difference), and you want the standard 5% significance level and 80% power. Plugging these into a standard two-proportion sample size formula (or any statistical software's sample size calculator) might return a required sample size of roughly 450 units per batch. If your production process can only realistically test 100 units per batch in a reasonable timeframe, you have two honest options: accept that the test is only powered to detect a much larger effect (say, a drop to 2%, an unrealistically large improvement to expect), or extend the test duration until enough units have been produced to reach the needed sample size. Running the test at 100 units per batch and interpreting a non-significant result as "no difference" would be a mistake — the test was simply never capable of detecting a difference of the size you actually cared about.
Common Pitfalls
Peeking
Peeking — checking test results as data accumulates and stopping as soon as a significant result appears — is one of the most common and most damaging mistakes in practical experimentation. Because random noise fluctuates around the true value, a test that is checked repeatedly has many chances for that noise to briefly cross the significance threshold even when no real effect exists, inflating the true false-positive rate well above the nominal 5% you intended. The fix is to determine the required sample size in advance via a power calculation, commit to collecting exactly that much data before evaluating significance, and resist the temptation to stop early on a promising-looking interim result — or, if early stopping is genuinely operationally necessary, use a formal sequential testing method (such as a group sequential design or an always-valid p-value approach) specifically built to control the false-positive rate under repeated looks.
The Multiple Comparisons Problem
Testing many hypotheses at once — comparing five different process settings simultaneously, or checking ten different outcome metrics for a single A/B test — multiplies the chance that at least one comparison will appear significant purely by chance, even if no real differences exist anywhere. With 20 independent comparisons each run at α = 0.05, you would expect roughly one "significant" result on average from pure chance alone, even with no real effects present. Corrections such as the Bonferroni correction (dividing your significance threshold by the number of comparisons) or the less conservative Benjamini-Hochberg procedure adjust for this inflated risk, and should be applied whenever a test involves multiple simultaneous comparisons rather than a single pre-specified one.
Confounding Variables and Poor Randomization
The validity of an A/B test rests entirely on the two groups being genuinely comparable except for the one factor being tested. In engineering experiments, this means controlling for time-of-day effects, operator differences, ambient temperature, upstream material variation, and equipment wear — any of which can create a spurious apparent difference between groups if it happens to correlate with which group a sample was assigned to rather than being randomized across both groups. Random assignment of test units to condition A or B (rather than, say, testing all of batch A in the morning and all of batch B in the afternoon) is the single most important design choice for avoiding this problem.
Stopping Because the Result Confirms What You Expected
A more subtle pitfall is unconsciously applying more scrutiny to inconvenient results than to expected ones — running additional checks or excluding "outlier" data points only when a result contradicts the hypothesis you were hoping to confirm. Pre-registering the analysis plan (what metric will be measured, what sample size will be collected, what would count as a significant result) before looking at any data is a strong safeguard against this kind of unintentional bias, and is considered best practice in rigorous experimental science for exactly this reason.
Applying A/B Testing to Engineering Contexts
Comparing Two Control Algorithms
To compare a new control algorithm against an existing baseline on a machine or process, randomly assign operating cycles, batches, or time windows to run under algorithm A or algorithm B (rather than running A for a month, then switching entirely to B for the next month, which confounds the algorithm comparison with any drift in conditions over time). Measure a clearly defined outcome — energy consumption per unit, cycle time, tracking error — and apply the hypothesis test described above to determine whether the observed difference exceeds what random variation alone would produce.
Comparing Two Material Batches or Suppliers
When comparing two material batches or suppliers, randomize which batch is used across production runs (rather than using up batch A entirely before starting batch B), and hold every other process variable — machine, operator, ambient conditions — as constant as possible across both groups, or explicitly record and control for them if they cannot be held constant. Measure the outcome of interest (defect rate, strength, dimensional tolerance) and run the same statistical framework.
Comparing Two Process Settings
For comparing two settings of a controllable process parameter — two different cure temperatures, two different feed rates, two different pressure setpoints — the same logic applies: randomize which setting is used for a given production run within the test window, define the outcome metric and the minimum improvement worth detecting before starting, calculate the required sample size, and avoid checking results and stopping early. In processes where randomizing every run is impractical, a well-designed alternative is to alternate settings in a systematic but unpredictable pattern (not simply A-B-A-B, which can be confounded with any regular cyclical drift in the process) and to explicitly account for time-based trends in the analysis.
A Practical Checklist Before Running an Engineering Experiment
- Write down the null and alternative hypotheses and the outcome metric before collecting any data.
- Decide the minimum effect size that would actually be worth acting on — not just any statistically detectable difference.
- Run a sample size / power calculation using that effect size, your chosen significance level, and the expected variability of the outcome measurement.
- Randomize assignment to condition A or B as rigorously as the process allows, controlling for time, operator, and environmental confounds.
- Commit to the predetermined sample size and resist evaluating significance before that sample size is reached.
- If testing multiple outcomes or multiple conditions simultaneously, apply a multiple-comparisons correction to your significance threshold.
- Report both statistical significance (the p-value) and practical significance (the actual effect size and its real-world cost/benefit) before making a decision.
Applied with this discipline, A/B testing gives engineering teams the same rigor that has made controlled experimentation the gold standard in science for over a century — replacing "it seemed to work better" with a defensible, quantified answer to whether a change actually made a measurable difference.