October 26, 2026
This is a getting-started guide to running A/B tests in a real-world setting. It strikes a balance between practical implementation (how to actually run a test) and statistical theory (enough first principles required to reason through real-world problems).
Every test begins with a real-world problem. For example, imagine we are testing a new product feature to determine if it should be rolled out to all users. Currently, an online self-service help search bar is located at the bottom of our application. However, our in-person customer support by phone is overwhelmed, and we therefore want to increase self-service usage.
To make our example concrete, let’s use this scenario: We currently get 100 visitors a week, and 2 of them use the help platform. Therefore, our status-quo baseline is 2%. We want to increase that rate to 5%. For practical business reasons, we will not ship the product change unless we are confident it results in at least that 5% usage rate.
To test this, we will expose a random group of users to Control A (the status quo) and another random group to Treatment B (the new placement) to see if we can gather enough evidence that the product change works. Note: we randomize the users based on user_id.
Now that we understand the problem, we must lock in our statistical parameters before launching the experiment. Defining these upfront prevents us from moving the goalposts later:
Here is a visual displaying the experiment design parameters:
With our parameters defined, our next step is to determine how many users we need in our test. Given these parameters, we can calculate the exact sample size needed using any online calculator. The formula for minimum n-size needed is:
where
In this case, for a two-sample proportion test with a 50/50 split, we require a sample size of roughly 588 users per group (1,176 users total).
Why this matters practically: This dictates our minimum test duration. At ~100 visitors a week, we need to run the experiment for roughly 12 weeks to get to ~1,200 data points. (In the real world, you may want to run tests for longer and/or in full-week increments to dilute day-of-week seasonality effects).
Going back to our scenario where we determined that the minimum detectable effect was +3% (that came from a 2% baseline to a 5% minimum proportion for the feature change to ship). Now imagine if we had another scenario where our current baseline was 95% and we wanted the new proportion to be 98%. In that scenario, that is also a 3-point difference in Minimum Detectable Effect. However, moving from 2% to 5% is harder than moving from 95% to 98% because variance changes at the extreme ends of a percentage scale.
Nevertheless, we want a way to standardize the differences so that we can compare apples-to-apples. That is where Cohen’s h comes in. It is a mathematical formula that standardizes the difference between two proportions.
The formula for Cohen’s h is:
The table below summarizes the output of Cohen’s h value and whether that numeric value indicates a small, medium, or large effect in the difference between the two proportions.
| Benchmark | Cohen’s h Value | Context |
|---|---|---|
| Small Effect | ~0.2 | Subtle user behavior shift |
| Medium Effect | ~0.5 | Noticeable impact |
| Large Effect | ~0.8 | Major UX or feature transformation |
While Cohen’s h calculation was already baked into our sample size calculation behind the scenes, Cohen’s h is highly useful for post-hoc analysis.
For example, if you are resource-constrained and just ran a test on whatever n you could gather, Cohen’s h helps quantify whether the statistically significant result you achieved is actually a meaningful shift in user behavior.
Let’s say you launch the experiment, and now it’s been 12 weeks. After running the experiment and gathering our 1,176 data points, our dataset looks like a ledger of binary outcomes:
To determine if there is a statistically significant difference between the two proportions, we run a Two-Sample Proportion Z-Test. If the resulting p-value is less than our alpha (0.05), we reject the null hypothesis and confidently launch the feature.
Note: For more information on hypothesis testing, especially when sample sizes are small and/or the underlying data is not normally distributed (thereby requiring non-parametric tests), check out my deeper guide on Hypothesis Testing here.
In a perfect world, a single Z-test is all you need. However, real-world realities often complicate our clean experimental design.
What happens if we test multiple treatments at once?
For example, we have Control A and Treatment B currently. But what if we also have Treatment C and Treatment D, which are other variants of treatment B. Let’s say Treatment B moves the search bar to the top of the page. Treatment C might have the search bar at the bottom of the page but in big bold letters. Treatment D might have the search bar at the bottom of the page but in red text.
If we tested each variant independently, each variant would carry a 5% chance of a Type I error (sounding a false alarm), as designed above. However, when evaluating three variants against a control simultaneously, the probability of at least one false positive compounds. This is known as the Family-Wise Error Rate (FWER). It can be calculated as:
With 3 treatments, our real false positive rate jumps to ~14%.
The Fix: We must have a stricter probability threshold to reject the null hypothesis. We therefore apply the Bonferroni correction, recalculating our target alpha as α / m.
For three tests, our new threshold for significance becomes .
Similarly, if you track your primary metric alongside 20 secondary metrics (e.g., sign-up rates, click-through rates, average purchase size, etc.), there is a ~64% chance that at least one of those secondary metrics will show a statistically significant difference purely by chance.
The Fix:
Even if your p-value screams “success,” you cannot trust it until you verify that the experiment’s underlying mechanics and user behaviors didn’t artificially skew the data.
If we design a 50/50 split, we won’t get an exact 50.0% / 50.0% distribution due to random noise—we might observe a 52/48 split. To verify whether this is harmless noise or a broken randomization pipeline, we run a Chi-Square Goodness-of-Fit Test comparing our observed traffic split against our expected 50/50 split.
Different user segments naturally behave differently. In our scenario, mobile users might, for example, use the self-service search bar at a much higher baseline rate than desktop users. If our randomization is unbalanced across these segments, or if we change traffic allocation percentages mid-test (ramping up Treatment B from 10% to 50% while weekend mobile traffic spikes), we might trigger Simpson’s Paradox.
Existing users have muscle memory, which can temporarily distort experiment results in two opposite ways:
How to Diagnose and Fix:
Beyond standard metrics, you might encounter metrics that don’t fit perfectly into our straightforward Z-test structure. To understand Ratio Metrics and the Delta Method, we first have to recognize that every A/B test has a Unit of Randomization (how we split traffic, which is almost always by User) and a Unit of Analysis (what we are actually counting in the denominator of our metric).
Everything is easy when those two units match. Ratio metrics—and the headache that requires the Delta Method—happen when those two units do not match.
In our playbook’s current example, we are randomized at the User level (Control A vs. Treatment B).
Here, the denominator is Users. Because we randomized by User and our denominator is Users, every single row in our dataset is 100% independent. User 1’s behavior has zero impact on User 2’s behavior. Our normal Z-test and standard error formula work out of the box.
Now, let’s introduce a Ratio Metric to our scenario:
Suppose we say, “Looking at whether a user used the search bar once isn’t enough. Some users log in 10 times a week. We want to know if moving the search bar to the top of the page increases the rate at which the search bar is used per session (or per pageview).”
Other classic business examples of ratio metrics include:
Remember how our Standard Error formula () is the bedrock of our confidence intervals and p-values? (See Appendix for more information). That formula relies on one strict mathematical rule: every observation in the denominator (N) must be completely independent.
When your denominator is Sessions instead of Users, you violate that rule in two ways:
Because you are dividing one random, noisy user-level number by another random, noisy user-level number, the normal variance formula completely falls apart.
So, how do we calculate the variance (and Standard Error) when our metric is a ratio of two random user-level variables (User Searches / User Sessions)? Enter the Delta Method.
Without getting bogged down in calculus, here is the pure intuition of what the Delta Method does:
The Business Intuition of the Result:
When you run your data through the Delta Method formula, it spits out a corrected, honest Standard Error.
Because it recognizes that 5,000 sessions came from only 588 independent users (and adjusts for heavy power users via the covariance), the Delta Method gives you a wider, more realistic confidence interval.
Once the Delta Method gives you that corrected Standard Error, you go right back to your normal playbook: you plug that new Standard Error into your Z-test or Confidence Interval () and make your business decision safely.
Once you master standard A/B testing, you will inevitably run into real-world business constraints (e.g., limited engineering bandwidth, overlapping experiments, small traffic volumes, or interconnected user bases) that require specialized methodologies:
This playbook focuses on a binomial (binary) distribution: users either clicked the search bar or they didn’t. If your primary metric is continuous (e.g., average checkout spend increasing from $100 to $105), three fundamental things change in your design:
| Dimension | Binomial (Binary) | Continuous |
|---|---|---|
| Sample Size Input | Variance derived purely from proportions | Requires historical variance (standard deviation) |
| Statistical Test | 2-Sample Z-Test for Proportions | 2-Sample T-Test (Welch’s T-Test) |
| Effect Size Metric | Cohen’s h | Cohen’s d |
In academia, the Central Limit Theorem (CLT) is often taught as an exercise: if you take infinite samples (B = ∞) of size n from a population, the distribution of those sample means will form a normal curve, called the sampling distribution. This sampling distribution has a mean and standard deviation. The mean of the sampling distribution is the population mean, and the standard deviation of the sampling distribution is called the standard error (SE). The Standard Error is important because that lets us determine confidence intervals, or the range in which we can be confident in our estimation of the population mean.
This academic exercise is all to demonstrate that the standard error is inversely proportional to the square root of N—as sample size goes up, standard error goes down. (Intuition: the bigger the sample size, the extreme values get averaged out more, placing the sample mean closer to the true population mean, and therefore there is less wobble around the true population mean when building a sampling distribution).
The formula for SE for proportions, as shown by the CLT, is:
where p̂ is the sample proportion, and an estimate of the true population proportion.
In the real world of A/B testing, however, we don’t take multiple samples. We take exactly one sample (one n of 1,176 users) (B=1). Because the CLT proves that standard error relies on N, we don’t need to pull multiple samples. We just need to ensure our single n is large enough. Once we hit our calculated sample size, we can confidently lean on the mathematics of the normal distribution to calculate our p-value. Similarly, because we know the standard error of the sampling distribution through the formula above, we can calculate the confidence interval, using (at 95% confidence level).
You might ask: doesn’t SE also rely on the variance of the sample (p̂)*(1-p̂); and if we took another sample, the variance of that sample would be different; and therefore the SE and confidence would be different? Yes, that is true. However:
When we calculate a 95% confidence interval (e.g., [3.77%, 6.23%]) from our single A/B test, it is tempting to say, “There is a 95% chance the true conversion rate is in this specific range.” Technically, this is false. The true population parameter is a fixed, invisible number; it is either inside our specific range (100% chance) or it isn’t (0% chance). We just don’t know which.
What it actually means: If we repeated this exact A/B test 100 times (B = 100), pulling 100 brand new samples of n = 1,176 users and calculating 100 different sample proportions (p̂) and therefore different confidence intervals, the mathematics guarantee that 95 of those 100 intervals would successfully capture the true population parameter. We trust our single result because we trust the rigorous methodology that produced it.
Here’s an analogy using lottery tickets: Think of the true, unknown population parameter as a fixed, secret winning number. It never moves or changes, and it remains completely invisible to us. When we design an A/B test with a 95% confidence level (α = 0.05), our statistical methodology acts like a printing press that generates a bucket of 100 lottery tickets:
(We could design our methodology to print 99 winners and only 1 loser if we wanted to be stricter, which would require a much larger sample size or a wider net (confidence interval). But in most real-world situations, we generally accept the 95/5 split as the practical sweet spot.)
In the real world, running a single A/B test means reaching into that bucket and pulling out just one ticket at random. Because the true population parameter is invisible, we can never scratch off the ticket to see if our specific range caught the winning number. Our single ticket is strictly binary: it is either a 100% winner or a 0% loser.
Therefore, saying “there is a 95% chance the true parameter is inside our interval” is technically false. Instead, we say “we have 95% confidence” that our interval captures the true parameter because we know the methodology we used to pull that single ticket succeeds 95 out of 100 times.
Part of the Applied Data Science Lab · Experimentation