<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mathias Paulenko</title>
    <description>The latest articles on DEV Community by Mathias Paulenko (@mathiaspaulenko).</description>
    <link>https://dev.to/mathiaspaulenko</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4271998%2F5780c517-5de0-4153-84ca-4b443187d32b.png</url>
      <title>DEV Community: Mathias Paulenko</title>
      <link>https://dev.to/mathiaspaulenko</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mathiaspaulenko"/>
    <language>en</language>
    <item>
      <title>A/B Testing Guide: Design, Statistics and Pitfalls</title>
      <dc:creator>Mathias Paulenko</dc:creator>
      <pubDate>Sun, 29 Nov 2026 09:34:27 +0000</pubDate>
      <link>https://dev.to/mathiaspaulenko/ab-testing-guide-design-statistics-and-pitfalls-27ki</link>
      <guid>https://dev.to/mathiaspaulenko/ab-testing-guide-design-statistics-and-pitfalls-27ki</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;The first A/B test I ever ran went wrong in the most instructive way possible: we declared a winner on day four because the uplift looked clean, shipped it, and watched the effect melt away over the next two weeks. Novelty effect, small sample, a bit of wishful thinking — the statistics hadn't lied to us, we just hadn't bothered to listen to what they were actually saying. Most teams I know have some version of that story.&lt;/p&gt;

&lt;p&gt;A/B testing (split testing) is a controlled experiment: you split traffic between the current version (control) and a candidate (treatment), measure a pre-defined metric, and let statistics decide. Done well, it replaces opinion-based product debates with evidence. Done badly — underpowered samples, peeking, contaminated groups — it produces confident wrong answers, which is worse than guessing.&lt;/p&gt;

&lt;p&gt;And the hard part isn't the statistics. It's the discipline: pre-registered hypotheses, honest sample sizes, clean randomization, and resisting the urge to call a winner on day three. This guide walks the full lifecycle, from hypothesis to decision, plus the tooling options and the failure modes that quietly invalidate results — including the ones I had to learn by screwing up first.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to Use
&lt;/h2&gt;

&lt;p&gt;A/B testing fits when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You want to validate a hypothesis about user behavior&lt;/li&gt;
&lt;li&gt;You need to measure the impact of a UI, copy, pricing or algorithm change&lt;/li&gt;
&lt;li&gt;You're choosing between two or more implementations and need data to decide&lt;/li&gt;
&lt;li&gt;You want to optimize conversion funnels or engagement metrics&lt;/li&gt;
&lt;li&gt;Your organization wants to move from opinion-based to data-driven decisions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's the wrong tool when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;You don't have enough traffic.&lt;/strong&gt; If you can't reach the required sample size within about four weeks, the test either runs forever or ends underpowered. Use qualitative research, session replay or usability testing instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You can't randomize cleanly.&lt;/strong&gt; Changes users can compare directly (public pricing pages) or features that leak between users (shared carts, messaging) break the independence assumption. Use geo-experiments or switchback designs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The effect you want to detect is smaller than your noise floor.&lt;/strong&gt; If the minimum detectable effect is below what normal metric variance allows, fix measurement before experimenting — CUPED and triggered analysis help (see below).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The decision is irreversible.&lt;/strong&gt; Don't experiment on changes you can't roll back; measure them with &lt;a href="https://stackpractices.com/guides/canary-deployment-guide/" rel="noopener noreferrer"&gt;staged rollouts&lt;/a&gt; instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For progressive releases and experiment delivery rather than hypothesis testing, see &lt;a href="https://stackpractices.com/guides/feature-flags-guide/" rel="noopener noreferrer"&gt;Feature Flags: Progressive Release and Safe Experimentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Concepts
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Control (A)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The existing version, the baseline for comparison&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Treatment (B)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The new version being tested&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Primary Metric&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The key outcome measure that determines success&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Guardrail Metric&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A metric that must not degrade (latency, error rate, revenue)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Statistical Significance&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Probability that the observed difference isn't due to chance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;P-Value&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Probability of seeing the observed result if there's no real difference&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Power&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Probability of detecting a true effect when it exists&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Minimum Detectable Effect (MDE)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Smallest meaningful difference you want to detect&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Sample Ratio Mismatch (SRM)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;When observed group sizes diverge from the expected split — almost always a bug&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Designing Experiment Metrics
&lt;/h2&gt;

&lt;p&gt;Metric choice decides whether the experiment can answer the question at all. A good primary metric has four properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sensitive&lt;/strong&gt;: it actually moves when the treatment works. "Checkout completion rate" responds to a shorter checkout; "total revenue per month" responds to everything and is too noisy for most tests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attributable&lt;/strong&gt;: the change can plausibly affect it. A homepage redesign can't move retention 30 days out — don't measure it there.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measurable at scale&lt;/strong&gt;: you get clean, complete data for both groups without manual work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Aligned with the business&lt;/strong&gt;: the metric proxies something the company cares about. Click-through on a misleading button is easy to lift and worth nothing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rates and means behave differently. Proportion metrics (conversion rate, click-through) fit the z-test shown below. Continuous metrics (revenue per user, session duration) are usually right-skewed — a few whales dominate the mean — so use a two-sample t-test only if the distribution is roughly normal, or Mann-Whitney U / bootstrap methods otherwise. Ratio metrics (revenue per &lt;em&gt;session&lt;/em&gt;, items per &lt;em&gt;order&lt;/em&gt;) need delta-method variance or ratio-aware test support in your platform.&lt;/p&gt;

&lt;p&gt;Guardrail metrics exist to veto. Pick the small set that would make you stop the experiment regardless of the primary result: error rate, p95 latency, refund rate, unsubscribe rate. Three to five is typical; a guardrail that never fires is fine, a missing guardrail that should have fired is an incident.&lt;/p&gt;

&lt;p&gt;Teams running many experiments often consolidate into an &lt;strong&gt;Overall Evaluation Criterion (OEC)&lt;/strong&gt; — a weighted composite of the metrics that matter — so every experiment rolls up to one decision number instead of negotiating metric trade-offs test by test.&lt;/p&gt;

&lt;h2&gt;
  
  
  How an A/B Test Works
&lt;/h2&gt;

&lt;p&gt;Every experiment follows the same loop: form a hypothesis, size the sample, randomize users, collect data, analyze, and decide. The randomization step is where most experiments silently break — the statistics only work if control and treatment are truly comparable groups.&lt;/p&gt;

&lt;p&gt;Notice two things about the loop. First, the sample size calculation happens &lt;strong&gt;before&lt;/strong&gt; launch — it's what makes "run until significant" invalid as a stopping rule. Second, the final gate isn't just statistical significance: a real lift that's too small to justify implementation cost is still a "don't ship".&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-Step A/B Testing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Define the Hypothesis
&lt;/h3&gt;

&lt;p&gt;A good hypothesis is specific, measurable, and falsifiable. If you can't state what evidence would prove you wrong, you don't have a hypothesis — you have a hope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;# Hypothesis Template
&lt;/span&gt;
&lt;span class="gs"&gt;**We believe**&lt;/span&gt; that [change]
&lt;span class="gs"&gt;**will result in**&lt;/span&gt; [metric improvement]
&lt;span class="gs"&gt;**for**&lt;/span&gt; [user segment]
&lt;span class="gs"&gt;**because**&lt;/span&gt; [reasoning based on data/observation]

&lt;span class="gu"&gt;# Example
&lt;/span&gt;We believe that reducing checkout steps from 5 to 3
will result in a 5% increase in checkout completion rate
for mobile users
because analytics show 40% drop-off at step 4 on mobile.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before launch, write down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Primary metric&lt;/strong&gt; — the single metric that decides the experiment. One, not three.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Guardrail metrics&lt;/strong&gt; — things that must not degrade: error rate, p95 latency, refund rate, revenue per user. Define kill thresholds upfront ("stop the test if p95 grows &amp;gt;10%").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Target population&lt;/strong&gt; — which users are eligible, and how you'll handle logged-out traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MDE&lt;/strong&gt; — the smallest lift worth shipping. If a 0.5% improvement wouldn't pay for the implementation, don't size the experiment to detect it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Duration&lt;/strong&gt; — a fixed end date covering full weekly cycles, decided before you look at any data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Calculate Sample Size
&lt;/h3&gt;

&lt;p&gt;Sample size is determined by four inputs: baseline rate, MDE, significance level (alpha), and power. Get this wrong and everything downstream is noise.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Example: Sample size calculation for A/B test&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;scipy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stats&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;calculate_sample_size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;baseline_rate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="c1"&gt;# Current conversion rate&lt;/span&gt;
    &lt;span class="n"&gt;mde&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;               &lt;span class="c1"&gt;# Minimum detectable effect (absolute)&lt;/span&gt;
    &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;      &lt;span class="c1"&gt;# Significance level&lt;/span&gt;
    &lt;span class="n"&gt;power&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;      &lt;span class="c1"&gt;# Statistical power&lt;/span&gt;
    &lt;span class="n"&gt;ratio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;        &lt;span class="c1"&gt;# Ratio of treatment to control&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""
    Calculate required sample size per group for a two-proportion test.
    """&lt;/span&gt;
    &lt;span class="n"&gt;p1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;baseline_rate&lt;/span&gt;
    &lt;span class="n"&gt;p2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;baseline_rate&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;mde&lt;/span&gt;

    &lt;span class="n"&gt;z_alpha&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ppf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;z_beta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ppf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;power&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;pooled_p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;ratio&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;p2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;ratio&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;z_alpha&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pooled_p&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;pooled_p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ratio&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
        &lt;span class="n"&gt;z_beta&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;p2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;p2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;ratio&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

    &lt;span class="n"&gt;denominator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;p2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="c1"&gt;# Example: 20% baseline conversion, want to detect 2% absolute improvement&lt;/span&gt;
&lt;span class="n"&gt;sample_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate_sample_size&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;baseline_rate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;mde&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.02&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;power&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.80&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Required sample size per group: {sample_size}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# Output: ~6,500 users per group&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What moves the number:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Baseline rate&lt;/strong&gt;: rates near 50% have maximum variance; very low rates (a 1% conversion) need huge samples to detect small absolute changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MDE&lt;/strong&gt;: the sample size grows with the square of precision — halving the MDE roughly quadruples the required sample.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Alpha&lt;/strong&gt;: 0.05 is standard; use 0.01 for high-stakes, hard-to-reverse changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Power&lt;/strong&gt;: 0.80 means you'd still miss a real effect 20% of the time. Don't go below it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the required sample exceeds your traffic, don't shrink the MDE to make it fit — increase the MDE by testing a bolder change, or accept that A/B testing isn't viable on that surface yet. For quick checks, &lt;a href="https://www.evanmiller.org/ab-testing/sample-size.html" rel="noopener noreferrer"&gt;Evan Miller's calculator&lt;/a&gt; is the standard reference.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Implement Assignment
&lt;/h3&gt;

&lt;p&gt;Assign users deterministically so each user sees the same version for the whole experiment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Example: Consistent user assignment&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_experiment_group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;experiment_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_groups&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""
    Deterministically assign user to experiment group based on hash.
    Ensures the same user always gets the same assignment.
    """&lt;/span&gt;
    &lt;span class="n"&gt;hash_input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{experiment_name}:{user_id}"&lt;/span&gt;
    &lt;span class="n"&gt;hash_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;md5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hash_input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hash_value&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;num_groups&lt;/span&gt;

    &lt;span class="n"&gt;groups&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"control"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"treatment"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;num_groups&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"group_{i}"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_groups&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;bucket&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# Usage&lt;/span&gt;
&lt;span class="n"&gt;user_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"user-12345"&lt;/span&gt;
&lt;span class="n"&gt;experiment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"checkout-redesign"&lt;/span&gt;
&lt;span class="n"&gt;group&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_experiment_group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;experiment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"User assigned to: {group}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Render appropriate UI&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;group&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"treatment"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;render_new_checkout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;render_old_checkout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Assignment has four requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Random&lt;/strong&gt;: every eligible user has an equal chance of each group.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistent&lt;/strong&gt;: the same user always sees the same version — including across sessions and devices, which means keying on a stable user ID, not a cookie.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Independent&lt;/strong&gt;: assignment to experiment A can't correlate with assignment to experiment B; include the experiment name in the hash input, as above.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sticky&lt;/strong&gt;: the assignment persists for the whole experiment. Re-randomizing mid-flight contaminates both groups.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before trusting your bucketing, run an &lt;strong&gt;A/A test&lt;/strong&gt;: split users into two identical groups and confirm that group sizes and all metrics match within noise. If an A/A test shows "significant" differences, your randomization or instrumentation is broken — fix it before running real tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Run the Experiment
&lt;/h3&gt;

&lt;p&gt;Collect data while maintaining experiment integrity. The two rules that matter most: don't peek, and don't touch a running experiment.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Checkpoint&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Day 1&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Verify randomization (group sizes match the expected split) and that events fire for both variants&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Day 3&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Check instrumentation health and guardrail metrics, not primary-metric significance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Midpoint&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Resist peeking at p-values; only check that data quality holds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;End date&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Run the analysis on the pre-committed sample&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Post-analysis&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Segment by device, geography, and user type before deciding&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Example: Experiment result analysis (two-proportion z-test)&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;statsmodels&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;proportion&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;proportions_ztest&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;analyze_experiment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;control_converted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;control_total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="n"&gt;treatment_converted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;treatment_total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;control_rate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;control_converted&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;control_total&lt;/span&gt;
    &lt;span class="n"&gt;treatment_rate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;treatment_converted&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;treatment_total&lt;/span&gt;

    &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;proportions_ztest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;control_converted&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;treatment_converted&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;control_total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;treatment_total&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;relative_lift&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;treatment_rate&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;control_rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;control_rate&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s1"&gt;'control_rate'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;control_rate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'treatment_rate'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;treatment_rate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'relative_lift'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;relative_lift&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'p_value'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;p_value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'significant'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;p_value&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;proportions_ztest&lt;/code&gt; lives in &lt;code&gt;statsmodels&lt;/code&gt;, not &lt;code&gt;scipy&lt;/code&gt; — the wrong import is the most common bug in homegrown analysis scripts. For continuous metrics (revenue, time-on-page) use a two-sample t-test or Mann-Whitney U for skewed distributions; see the &lt;a href="https://www.statsmodels.org/stable/generated/statsmodels.stats.proportion.proportions_ztest.html" rel="noopener noreferrer"&gt;statsmodels docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Monitoring during the run is about health, not results — error rates, latency, and event volume are covered well by the practices in the &lt;a href="https://stackpractices.com/guides/complete-guide-observability-grafana-stack/" rel="noopener noreferrer"&gt;observability guide&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Interpret Results
&lt;/h3&gt;

&lt;p&gt;Decide on statistical &lt;strong&gt;and&lt;/strong&gt; practical significance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;# Result Interpretation Framework
&lt;/span&gt;
&lt;span class="gu"&gt;## Statistical Significance
&lt;/span&gt;&lt;span class="k"&gt;- &lt;/span&gt;p-value &amp;lt; 0.05: result is statistically significant
&lt;span class="k"&gt;- &lt;/span&gt;p-value &amp;gt;= 0.05: not enough evidence to reject the null hypothesis

&lt;span class="gu"&gt;## Practical Significance
&lt;/span&gt;&lt;span class="k"&gt;- &lt;/span&gt;Is the lift large enough to justify implementation cost?
&lt;span class="k"&gt;- &lt;/span&gt;Does the lift persist across segments (new vs returning, mobile vs desktop)?
&lt;span class="k"&gt;- &lt;/span&gt;Are guardrail metrics healthy?

&lt;span class="gu"&gt;## Decision Matrix
&lt;/span&gt;| Statistically Significant | Practically Significant | Decision |
|---------------------------|-------------------------|----------|
| Yes | Yes | Ship it |
| Yes | No | Don't ship — the cost exceeds the benefit |
| No | Yes | Run longer or increase the sample next time |
| No | No | Don't ship; document the learning |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two habits that separate mature experiment programs from cargo-cult ones. First, report &lt;strong&gt;confidence intervals&lt;/strong&gt;, not just the p-value — "between +0.3% and +4.1% conversion" is a decision input; "p=0.03" isn't. Second, write down the decision and rationale for every experiment, including inconclusive ones — that's the institutional memory that prevents re-running the same test a year later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing Experimentation Tooling
&lt;/h2&gt;

&lt;p&gt;The build-vs-buy decision hinges on where your data lives and who runs the experiments:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DIY (hash + warehouse)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Custom&lt;/td&gt;
&lt;td&gt;Small teams, few experiments, full control. The code above is most of what you need — the cost is building trustworthy analysis and an experiment registry.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;GrowthBook&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Open source, warehouse-native&lt;/td&gt;
&lt;td&gt;Teams that want self-hosted or warehouse-connected experimentation with SQL-based metrics and Bayesian/frequentist engines.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Statsig&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;SaaS or warehouse-connected&lt;/td&gt;
&lt;td&gt;Product experiments at scale; built-in sequential testing (mSPRT), feature gates, and strong diagnostics like automatic SRM detection.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Eppo&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Warehouse-native SaaS&lt;/td&gt;
&lt;td&gt;Organizations whose metrics already live in the warehouse and want analysis to run there too.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Optimizely / VWO&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;SaaS with visual editor&lt;/td&gt;
&lt;td&gt;Marketing and website experiments where non-engineers need to create variants without deploys.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A few guidelines from teams that have made this choice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start simple if your experiment volume is low — a hash function plus a query beats a platform nobody logs into.&lt;/li&gt;
&lt;li&gt;If you buy, prioritize &lt;strong&gt;automatic SRM detection&lt;/strong&gt; and &lt;strong&gt;sequential testing support&lt;/strong&gt;; those two features prevent the two most common ways experiments go wrong.&lt;/li&gt;
&lt;li&gt;Warehouse-native tools keep analysis next to your real metrics and avoid maintaining a parallel event pipeline.&lt;/li&gt;
&lt;li&gt;Whatever you choose, the experiment should be documented in one registry: hypothesis, owner, dates, decision. Experimentation without a registry becomes folklore within months.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When Experiments Go Wrong
&lt;/h2&gt;

&lt;p&gt;These are the failure modes that invalidate results without throwing an error:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sample ratio mismatch (SRM)&lt;/strong&gt;: you configured a 50/50 split but observe 51.2/48.8 with thousands of users. That gap is almost never chance — it signals a randomization bug, bot traffic, or telemetry loss in one variant. Check it with a chi-square test on group counts; Statsig and similar tools alert on it automatically. If you see SRM, stop and fix the plumbing — nothing downstream is valid.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Peeking&lt;/strong&gt;: checking significance daily turns a 5% false-positive rate into roughly 20-30%. Either commit to a fixed end date or use sequential testing methods designed for continuous monitoring.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Instrumentation bugs&lt;/strong&gt;: the treatment "loses" because its events never fired. Validate tracking in an A/A test before launch, and compare event volume per user across groups, not just totals.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interaction effects&lt;/strong&gt;: two simultaneous experiments on the same surface contaminate each other. Use mutually exclusive layers, or accept the noise only if the experiments touch genuinely independent metrics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Novelty and primacy effects&lt;/strong&gt;: new features get an engagement spike from curiosity; returning users punish unfamiliar changes for a week. Segment new vs returning users — if the lift only exists in one group, wait.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Guardrail degradation&lt;/strong&gt;: conversion went up 3% while error rate doubled. Without pre-defined guardrails you ship a regression. If any guardrail breaches its kill threshold, end the test regardless of the primary metric.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Seasonality and external events&lt;/strong&gt;: a test running over Black Friday or an outage measures the event, not your change. Run full weekly cycles and record external events in the experiment log.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Reducing Variance and Running Faster Tests
&lt;/h2&gt;

&lt;p&gt;Once the basics are solid, these techniques buy you sensitivity without more traffic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CUPED (Controlled-experiment Using Pre-Experiment Data)&lt;/strong&gt;: adjust each user's metric by their pre-experiment behavior to remove between-user variance. Microsoft reported ~50% variance reduction on many metrics, which is like doubling your traffic for free. Every serious platform supports it; see the &lt;a href="https://www.microsoft.com/en-us/research/publication/improving-the-sensitivity-of-online-controlled-experiments-by-utilizing-pre-experiment-data-cuped/" rel="noopener noreferrer"&gt;original Microsoft Research publication&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Triggered analysis&lt;/strong&gt;: only include users who could actually see the change. Analyzing your full user base when the treatment only affects the checkout page dilutes the effect into noise.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stratified assignment&lt;/strong&gt;: force balance on key covariates (country, plan tier, device) at assignment time instead of hoping randomization produces comparable groups.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cluster randomization&lt;/strong&gt;: when users interact (social features, shared workspaces), randomize groups rather than individuals so treatment can't leak through user-to-user contact.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Switchback designs&lt;/strong&gt;: for marketplaces where treatment affects shared supply (pricing, dispatch algorithms), randomize time windows instead of users — the approach Uber and DoorDash use because user-level randomization is impossible there.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Works
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run experiments for full weeks — a test that skips a weekend or starts mid-week inherits day-of-week bias that no sample size fixes.&lt;/li&gt;
&lt;li&gt;Avoid peeking. Checking significance daily turns a 5% false-positive rate into roughly 20-30%.&lt;/li&gt;
&lt;li&gt;Use one primary metric. The moment you allow three, every outcome can be framed as a win.&lt;/li&gt;
&lt;li&gt;Pre-register the decision criteria — hypothesis, MDE, duration and kill thresholds written down before the first data point.&lt;/li&gt;
&lt;li&gt;Run an A/A test on new infrastructure. It costs a week and catches broken bucketing before it produces fake wins.&lt;/li&gt;
&lt;li&gt;Document every experiment — hypothesis, design, decision and reasoning. A year later, the registry is the only thing stopping you from re-running the same test.&lt;/li&gt;
&lt;li&gt;Segment results before deciding. An aggregate win can hide a loss in a segment big enough to matter (new users, mobile, a specific market).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common Mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Testing more than two variants without correcting for multiple comparisons — use Bonferroni or sequential testing methods.&lt;/li&gt;
&lt;li&gt;Underpowered experiments. Small samples can't detect small but meaningful effects.&lt;/li&gt;
&lt;li&gt;Reading a "no effect" result as proof there's none. An underpowered null means the test couldn't detect the effect — check the confidence interval's upper bound before calling the change neutral.&lt;/li&gt;
&lt;li&gt;Declaring victory on a post-hoc segment. If "mobile users in Canada" wasn't a pre-registered hypothesis, it's a lead for the next test, not a result.&lt;/li&gt;
&lt;li&gt;Confusing novelty with preference. New capabilities get initial engagement spikes that fade.&lt;/li&gt;
&lt;li&gt;Changing running experiments. Never modify the treatment mid-experiment — redeploy as a new test instead.&lt;/li&gt;
&lt;li&gt;Rolling out to 100% the day a test ends. A lift measured on 5% of traffic can hide costs that only appear at scale — ship through a staged rollout.&lt;/li&gt;
&lt;li&gt;Shipping on an inconclusive result because "it looked positive". Flat results are also information; they mean the change wasn't worth it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Variants
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A/B/n testing&lt;/strong&gt;: test more than two variants (A/B/C/D). Requires correcting for multiple comparisons and much larger samples.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multivariate testing (MVT)&lt;/strong&gt;: test combinations of changes to several elements at once (headline × image × button) to estimate interaction effects — different from simply adding more variants.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sequential testing&lt;/strong&gt;: analyze continuously without inflating the false-positive rate, using alpha-spending or mSPRT methods.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bandit algorithms&lt;/strong&gt;: dynamically shift traffic toward better-performing variants — good for short-lived optimization (headlines), weaker for clean causal measurement.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Holdout groups&lt;/strong&gt;: keep a long-term control group to measure the cumulative impact of many shipped changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Geo-experiments&lt;/strong&gt;: randomize by geography for changes that can't be user-randomized, like pricing or offline marketing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How long should an A/B test run?
&lt;/h3&gt;

&lt;p&gt;Minimum 1-2 full weeks to capture weekly cycles, and until you reach the pre-calculated sample size — whichever comes later. Ending early because you hit significance mid-week is the most common way experiments produce fake wins.&lt;/p&gt;

&lt;h3&gt;
  
  
  What if my treatment shows a 50% improvement?
&lt;/h3&gt;

&lt;p&gt;Assume a bug until proven otherwise. Lifts that large usually mean double-counted events, a broken control, or SRM — verify the instrumentation and group split before celebrating.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I run two or more A/B tests at the same time?
&lt;/h3&gt;

&lt;p&gt;Yes, if the experiments are independent: different surfaces, different metrics, or mutually exclusive assignment layers. Overlapping tests on the same funnel create interaction effects that make both results unreadable.&lt;/p&gt;

&lt;h3&gt;
  
  
  What p-value threshold should I use?
&lt;/h3&gt;

&lt;p&gt;0.05 for most product decisions, 0.01 for high-stakes or hard-to-reverse changes (pricing, core algorithms). Whatever you choose, commit to it before the experiment starts — picking the threshold after seeing results is p-hacking.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a sample ratio mismatch?
&lt;/h3&gt;

&lt;p&gt;When observed group sizes diverge from the configured split beyond chance — say 51/49 instead of 50/50 on a large sample. It's almost always a symptom of broken randomization, bots, or lost telemetry, and it invalidates the whole experiment until fixed.&lt;/p&gt;

&lt;h3&gt;
  
  
  What if I don't have enough traffic for the required sample size?
&lt;/h3&gt;

&lt;p&gt;Don't shrink the MDE to fit your traffic — increase it by testing a bolder change, extend the duration (up to ~4 weeks max before cohort drift becomes a problem), reduce variance with CUPED, or use qualitative methods on that surface until traffic grows.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I build or buy an experimentation platform?
&lt;/h3&gt;

&lt;p&gt;Build if your volume is low and your metrics live in a warehouse — a hash function plus SQL gets you surprisingly far. Buy when experiment volume grows, non-engineers need to launch tests, or you want SRM detection and sequential testing without maintaining them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Evan Miller's A/B testing tools&lt;/strong&gt;: the &lt;a href="https://www.evanmiller.org/ab-testing/sample-size.html" rel="noopener noreferrer"&gt;sample size calculator&lt;/a&gt; and related articles are the standard reference for experiment math.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;statsmodels documentation&lt;/strong&gt;: the &lt;a href="https://www.statsmodels.org/stable/generated/statsmodels.stats.proportion.proportions_ztest.html" rel="noopener noreferrer"&gt;&lt;code&gt;proportions_ztest&lt;/code&gt;&lt;/a&gt; reference for analyzing conversion metrics in Python.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CUPED paper&lt;/strong&gt;: Microsoft's &lt;a href="https://www.microsoft.com/en-us/research/publication/improving-the-sensitivity-of-online-controlled-experiments-by-utilizing-pre-experiment-data-cuped/" rel="noopener noreferrer"&gt;Improving the Sensitivity of Online Controlled Experiments&lt;/a&gt; explains the variance-reduction technique every major platform uses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trustworthy Online Controlled Experiments&lt;/strong&gt; (Kohavi, Tang, Xu — Cambridge University Press): the field's reference book, drawn from experiments at Bing, Google and LinkedIn.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GrowthBook docs&lt;/strong&gt;: the &lt;a href="https://docs.growthbook.io" rel="noopener noreferrer"&gt;open-source platform's documentation&lt;/a&gt; is a practical reference for experiment configuration and metric design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Companion files&lt;/strong&gt;: the &lt;a href="https://mathiaspaulenko.github.io/stack-practices-resources/resources/guides/deployment/a-b-testing-guide/" rel="noopener noreferrer"&gt;a-b-testing-guide companion repo&lt;/a&gt; packages the sample-size calculator, assignment function, analysis script and hypothesis template from this guide as standalone files.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;A/B testing turns product development from opinion-driven to evidence-driven — but only when the discipline holds. The methodology is simple; the rigor isn't. Pre-register your hypothesis and decision criteria, size the sample honestly, verify the plumbing with A/A tests and SRM checks, and treat every inconclusive result as a documented answer, not a failed experiment. Teams that do this compound their learnings; teams that peek and ship on vibes get confidently wrong answers.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://stackpractices.com/guides/a-b-testing-guide/" rel="noopener noreferrer"&gt;StackPractices&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>analytics</category>
    </item>
  </channel>
</rss>
