---
title: Sequential Probability Ratio Tests
description: Learn about SPRT methodology for faster A/B test decision making with no penalties for peeking.
product: general
lang: en
token_estimate: 2046
---
# Sequential Probability Ratio Tests

The sequential probability ratio test (SPRT) decides an A/B test by comparing how likely your data is under the alternative hypothesis versus the null hypothesis, and stops when that likelihood ratio crosses an upper or lower boundary set from your alpha and beta. You can read results at any time with no peeking penalty. Additionally, you can accept the null hypothesis as well as the alternative. Before the experiment starts, you set a [minimum detectable effect (MDE)](https://docs.statsig.com/experiments/power-analysis#variables-the-calculator-estimates) for each metric. SPRT also needs each metric's [baseline mean and standard deviation](#power-analysis-and-setting-cohens-d). By default, Statsig takes these from the experiment's control group, or you can enter them yourself.

> For AI agents: a documentation index is available at [/llms.txt](/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

To use SPRT, go to your experiment's _Setup_ tab, expand _Advanced Settings_, and set _Analytics Type_ to **SPRT** under _Analysis Configuration_.

![SPRT experiment results scorecard](https://docs.statsig.com/images/experiments/sprt/sprt_scorecard.png)

## Likelihood ratio and decision boundaries

SPRT relies on the likelihood ratio (LR) and on upper and lower decision boundaries, A and B.

The likelihood ratio compares the likelihood of two explanations for what you observe:

- **Numerator**: The likelihood of the observed data if the alternative hypothesis, which you set, is correct.
- **Denominator**: The likelihood of the observed data if the null hypothesis is correct.

An LR of 5.8 means that what you observed is 5.8 times more likely under the alternative hypothesis than under the null hypothesis. You can report a result as "With an LR of 3.5, it's 3.5 times more likely that the feature worked."

Your tolerances for Type I error (alpha) and Type II error (beta) determine the decision boundaries:

- **A**: If the LR exceeds this upper boundary, accept the alternative hypothesis.
- **B**: If the LR falls below this lower boundary, accept the null hypothesis.
- If the LR falls between the boundaries, continue collecting data.

![SPRT Hover Card](https://docs.statsig.com/images/experiments/sprt/sprt_hover_card.png)

## How SPRT differs from sequential testing

SPRT is a separate procedure from the sequential testing option. [Sequential testing](https://docs.statsig.com/experiments/advanced-setup/sequential-testing) adjusts a frequentist analysis to allow repeated looks at results; SPRT is a different decision framework. Both allow continuous looks at experiment results, but they're otherwise separate methods for designing and running an A/B test.

SPRT isn't a drop-in replacement for frequentist methods. It requires thresholds and baseline assumptions for each metric, and for some experiment types traditional methods remain preferable. For a side-by-side comparison of the three analysis methods, refer to [Compare analysis methods](https://docs.statsig.com/experiments/statistical-methods/introduction#compare-analysis-methods).

## Enable SPRT

1. Go to the experiment's _Setup_ tab and expand _Advanced Settings_.
2. Under _Analysis Configuration_, set _Analytics Type_ to **SPRT**. Selecting it reveals _SPRT Settings_, which holds the default confidence interval, the **Power Parameter**, a **Make all metrics one-sided** option, and _SPRT Sensitivity_.
3. Under _SPRT Sensitivity_, choose a **Baseline Mode**:

   - **Use experiment control group**: Statsig derives each metric's mean and standard deviation from the experiment's own control group. This is the recommended option. Set only an **MDE (%)**, either one default for all metrics or a value for each metric.
   - **Manual setup**: Set Cohen's d for each metric yourself by supplying an **MDE (%)**, a **Mean**, and a **Standard Deviation**, as described in [Power analysis and setting Cohen's d](#power-analysis-and-setting-cohens-d). To fill these from a previous experiment instead of typing them, pick that experiment under _Fetch baseline values from past experiment_ and select **Run Query**.

   In both modes, the per-metric table shows each metric's **Testing Direction**. In Manual setup, it also shows each metric's **Estimated Decision Sample Size**. Set these values before the experiment starts.

## Interpret SPRT results

The experiment Results tab shows the latest likelihood ratio for each metric and indicates when a metric reaches a decision boundary, so you can accept the null or alternative hypothesis.

![SPRT experiment results dashboard](https://docs.statsig.com/images/experiments/sprt/sprt_results_readout.png)

## Computing SPRT results

Statsig uses an updated version of [Hajnal's two-sample t test](https://www.jstor.org/stable/2333131) ([Schnuerch and Erdfelder](https://doi.org/10.1037/met0000234), as modified by Derek Ho of Atlassian) in its SPRT calculations. The traditional ratio test using t- or F-distributions (Schnuerch and Erdfelder equations 8 and 10) simplifies to a ratio of standard normal distributions.

$$
\begin{split}
{LR}
&= \frac
{f(t^2| {df}, \Delta)}
{f(t^2| {df}, 1)} \\
&= \frac
{\phi(|z_{m}|; \theta, 1)}
{\phi(|z_{m}|; 0, 1)} \\
\end{split}
$$

where:

- $\phi(x; \theta, 1)$ is the PDF of a normal distribution of shape $\mathcal{N}(\theta, 1)$ evaluated at $x$.
- $z$ is the observed z-statistic between the groups:

$$
z = \frac
{\Delta \bar{X}}
{\sigma_{\Delta\bar{X}}}
= \frac
{\bar{X}_B - \bar{X}_A}
{\sigma_{\Delta\bar{X}}}
$$

$$
\sigma_{\Delta\bar{X}}=\sqrt{\frac{var(X_A)}{N_A}+\frac{var(X_B)}{N_B}}
$$

- $\theta$ derives from Cohen's d, which you set before the experiment for the metric under consideration:

$$
\theta = \frac
{\delta}
{\sqrt{
\frac{1}{N_A} + \frac{1}{N_B}
}}
$$

- $N_A$ and $N_B$ are the number of observed units for each group.

Because log likelihood ratios are a more convenient scale for reporting, taking the natural log of the LR simplifies the equation further:

$$
\begin{split}
LLR
&= ln(LR) \\
&= |z_m \cdot \phi_m | - \frac{1}{2}{|\phi_m|}^2
\end{split}
$$

### Power analysis and setting Cohen's d

SPRT requires that you set a value of [Cohen's d](https://en.wikiversity.org/wiki/Cohen%27s_d) before the experiment starts for each metric you evaluate. Setting the parameter requires three components:

- **MDE**: A minimum detectable effect to measure, in units of percent.
- **Mean**: A baseline average value for the metric, $\overline{X}$.
- **Standard deviation**: A baseline standard deviation for the metric, $\sigma_{X}$.

With these values, you can compute the Cohen's d parameter for each metric:

$$
\delta = \frac{\text{MDE\%} \cdot \overline{X}}{100 \cdot \sigma_{X}}
$$

You can automate this process with Statsig's built-in query tooling. If a past experiment ran on a set of units similar to the ones you expect in the upcoming experiment, select it as the _Baseline Experiment_; a query then pulls the relevant metric parameters automatically. You can also enter all three parameters manually.

### Estimating the decision sample size

Statsig uses Cohen's d to compute experiment results after the experiment starts, and it can also estimate experiment duration in advance. Because SPRT lets you look at results as often as you want, this estimate isn't the same as the required sample size in traditional frequentist testing. The decision sample size is an estimate of the number of samples sufficient for a metric's SPRT result to exceed either boundary and accept one of the hypotheses. SPRT can shorten an experiment when the evidence for or against an effect is strong; if the effect is small or the data is noisy, the test may run longer than this estimate.

Given:

$$
A=ln\left(\frac{1-\beta}{\alpha}\right)
$$

$$
k=\frac{n_{ec}}{n_{et}}=\frac{\text{units expected in control}}{\text{units expected in treatment}}=\frac{\text{\% units expected in control}}{\text{\% units expected in treatment}}
$$

$$
n_{et} = \frac{A}{\frac{1}{2}\left(\frac{k}{1+k}\right)\delta^2}
$$

the total number of expected units at decision time is:

$$
n_e=n_{et}+n_{ec}=n_{et}(1+k)
$$

