Bandung 23.4 °C 1014.4 hPa

Why Does SPRT Need Boundary Functions? Complete Mathematical & Practical Guide

Key Takeaways

  • SPRT must have two boundary functions (upper and lower) because without boundaries, a sequential test lacks a stopping rule and never terminates [STAT: sprt-termination, tier 1, 1947]
  • Boundaries $A$ and $B$ are directly determined from target error rates $\alpha$ and $\beta$ via Wald's fundamental inequalities: $A \le \frac{1-\beta}{\alpha}$ and $B \ge \frac{\beta}{1-\alpha}$ [STAT: wald-boundaries, tier 1, 2012]
  • The overshoot phenomenon in discrete random walks makes the actual error rates more conservative than nominal targets: $\alpha_{\text{true}} + \beta_{\text{true}} \le \alpha + \beta$ [STAT: conservative-error, tier 2, 2022]
  • For $\alpha=0.05$ and $\beta=0.05$, the actual error rate is guaranteed to be $\le 0.0526$ — tighter than the target [STAT: error-example, tier 2, 2022]
  • SPRT reaches a decision with significantly fewer samples compared to a fixed-sample test with the same error rates [STAT: sprt-efficiency, tier 2, 2024]

Short Answer: Why Does SPRT Need Boundary Functions?

SPRT requires boundary functions because without decision boundaries, a sequential test has no stopping rule — meaning sampling would continue indefinitely with no mechanism to control either Type I ($\alpha$) or Type II ($\beta$) errors. Two boundary functions (upper to reject $H_0$, lower to accept $H_0$) create three decision regions that allow SPRT to terminate immediately once the evidence is strong enough, while guaranteeing error rate control through Abraham Wald's rigorous mathematical derivation.

Context: Why Is Sequential Analysis Different?

Classical hypothesis testing (fixed-sample test) determines the sample size $n$ upfront, collects all data, and makes a single decision at the end. This approach often wastes resources: even if the evidence is overwhelmingly clear halfway through, we are still forced to collect all $n$ samples. During World War II, Abraham Wald pioneered a different paradigm: sequential analysis — evaluating data as it arrives and stopping immediately once a decision can be made with the target confidence level.

[IMAGE: "decision-regions-diagram" | style: "diagram" | alt: "Three decision regions of SPRT: H0 acceptance region (green), H0 rejection region (red), and indifference/continue sampling region (white)"]

A brief history: Wald developed SPRT for the U.S. Navy Department to efficiently control ammunition quality. This problem had previously stumped Milton Friedman until Wald demonstrated the solution [STAT: sprt-efficiency, tier 2, 2024]. Today, SPRT serves as the foundation for modern sequential testing — from Computerized Adaptive Testing (CAT) to manufacturing quality control.

Anatomy of Boundary Functions: Three Decision Regions

SPRT boundary functions divide the decision space into three complementary regions:

1. $H_0$ Acceptance Region

The region where evidence supports the null hypothesis. If the test statistic enters this zone, we accept $H_0$ and stop sampling. The lower boundary $B$ defines the upper limit of this region.

2. $H_0$ Rejection Region

The region where evidence strongly opposes $H_0$. If the test statistic enters this zone, we reject $H_0$ (accept $H_1$) and stop sampling. The upper boundary $A$ defines the lower limit of this region.

3. Indifference / Continuation Region

The region between the two boundaries. Here, the evidence is not yet sufficient for either decision — we must continue sampling. This region is what distinguishes SPRT from fixed-sample tests: sampling continues only as long as uncertainty remains high.

[CHART: "parallel-boundaries-log-likelihood" | data: "log-likelihood random walk with upper boundary ln(A) and lower boundary ln(B)" | title: "Log-Likelihood Ratio Random Walk with Two Parallel Boundaries" | source: "OpenSTEM Library, Wikipedia 2025"]

In the log-likelihood ratio space, these two boundaries form parallel horizontal lines at heights $\ln A$ (upper) and $\ln B$ (lower). The random walk $S_n = \sum \ln(f_1/f_0)$ fluctuates up and down until it hits one of the boundaries — a classic analogy to the Gambler's Ruin / first-passage problem.

Mathematical Derivation: From $\alpha, \beta$ to Boundaries $A$ and $B$

This is the mathematical core explaining why boundary functions must exist and how their values are determined.

Likelihood Ratio as the Test Statistic

SPRT compares two simple hypotheses:

  • $H_0: \theta = \theta_0$
  • $H_1: \theta = \theta_1$

The test statistic is the likelihood ratio: $$\Lambda_n = \frac{L(\theta_1 \mid x_1,\dots,x_n)}{L(\theta_0 \mid x_1,\dots,x_n)} = \prod_{i=1}^n \frac{f_1(x_i)}{f_0(x_i)}$$

Taking the logarithm yields an additive random walk: $$S_n = \ln \Lambda_n = \sum_{i=1}^n \ln\left[\frac{f_1(x_i)}{f_0(x_i)}\right]$$

Wald's Fundamental Inequalities

Wald proved that to control error rates at levels $\alpha$ (Type I) and $\beta$ (Type II), the decision boundaries must satisfy:

$$A \le \frac{1 - \beta}{\alpha}$$ $$B \ge \frac{\beta}{1 - \alpha}$$

[STAT: wald-boundaries, tier 1, 2012] — These inequalities are distribution-free, holding true across the entire exponential family of distributions (binomial, Poisson, normal, exponential, etc.).

Brief Proof via Change of Measure

The intuition behind Wald's proof uses a change of probability measure (Radon-Nikodym derivative):

  1. Under $H_0$, $E_0[\Lambda_n] = 1$ (martingale property).
  2. The probability of rejecting $H_0$ when $H_0$ is true (Type I error) is $P_0(S_N \ge \ln A)$.
  3. Using indicator functions and the martingale property: $\alpha = P_0(\text{reject}) \le \frac{E_0[\Lambda_N]}{A} = \frac{1}{A}$.
  4. Thus, $A \ge \frac{1}{\alpha}$ (rough bound), which refines to $A \le \frac{1-\beta}{\alpha}$ when accounting for $H_1$.

[INTERNAL-LINK: "derivasi-lengkap-wald-sprt"]

Wald's Practical Approximations

In practice, Wald recommended the following approximations: $$A \approx \frac{1 - \beta}{\alpha}$$ $$B \approx \frac{\beta}{1 - \alpha}$$

[STAT: wald-boundaries, tier 1, 2012] — These approximations are remarkably accurate and are used as the default in most statistical software implementations (R, Python, SAS, Minitab).

The Overshoot Phenomenon: Why Actual Error Rates Beat Targets

This is a hidden advantage of SPRT that is rarely explained thoroughly.

What Is Overshoot?

The random walk $S_n$ moves in discrete steps (jumps). When approaching a boundary, the next step frequently jumps past (overshoots) the boundary rather than landing squarely on it.

[IMAGE: "overshoot-illustration" | style: "diagram" | alt: "Discrete random walk jumping past upper and lower boundaries — overshoot illustration"]

Consequence: Conservative Error Control

Because of overshoot, the probability of actually crossing a boundary is smaller than the nominal calculation. Consequently:

$$\alpha_{\text{true}} \le \frac{\alpha}{1 - \beta}$$ $$\beta_{\text{true}} \le \frac{\beta}{1 - \alpha}$$ $$\alpha_{\text{true}} + \beta_{\text{true}} \le \alpha + \beta$$

[STAT: conservative-error, tier 2, 2022] — At least one actual error rate is strictly tighter than its nominal target, and neither can exceed its target by more than $\alpha\beta$.

Concrete Numerical Example

For the industry standard $\alpha = 0.05, \beta = 0.05$:

  • $A \approx \frac{1 - 0.05}{0.05} = 19$
  • $B \approx \frac{0.05}{1 - 0.05} \approx 0.0526$
  • $\alpha_{\text{true}} \le 0.0526, \beta_{\text{true}} \le 0.0526$

[STAT: error-example, tier 2, 2022] — The actual error rate is $\le 5.26%$, virtually matching or beating the $5%$ target. This is a free bonus stemming from SPRT's discrete structure.

Boundary Functions Dictate Performance: OC Curve and ASN

The choice of boundary functions (via $\alpha, \beta$) directly determines the two primary performance metrics of SPRT:

1. Operating Characteristic (OC) Function

$$L(\theta) = P_\theta(\text{accept } H_0) = \text{probability of accepting } H_0 \text{ when the true parameter is } \theta$$

  • S-shaped curve: approaches $1$ when $\theta \approx \theta_0$, approaches $0$ when $\theta \approx \theta_1$.
  • Wider boundaries (smaller $\alpha, \beta$) $\rightarrow$ steeper OC curve (higher statistical power).

[CHART: "oc-curve-sprt" | data: "L(p) vs p for binomial SPRT with p0=0.1, p1=0.3, alpha=0.05, beta=0.05" | title: "Binomial SPRT Operating Characteristic (OC) Function" | source: "USD Dissertation 2007, OpenSTEM Library"]

2. Average Sample Number (ASN) Function

$$E_\theta[N] = \text{expected number of samples required when the true parameter is } \theta$$

  • Peaks in the indifference zone ($\theta$ between $\theta_0$ and $\theta_1$) — here evidence is most ambiguous, requiring the most samples.
  • Approaches $0$ when $\theta$ is far from the indifference zone (clear evidence leads to rapid decisions).

[CHART: "asn-curve-sprt" | data: "E[N] vs p for binomial SPRT" | title: "Binomial SPRT Average Sample Number (ASN)" | source: "OpenSTEM Library"]

[STAT: sprt-efficiency, tier 2, 2024] — SPRT's ASN is substantially smaller than the sample size $n$ of an equivalent fixed-sample test with the same power, especially at the parameter extremes.

Complete Case Study: SPRT for Proportions (Binomial)

Let's apply the theory to a real-world scenario: testing the defect proportion $p$ on a production line.

Problem Parameters

  • $H_0: p = p_0 = 0.05$ (good quality)
  • $H_1: p = p_1 = 0.15$ (poor quality)
  • $\alpha = 0.05, \beta = 0.10$

Calculate Boundaries $A$ and $B$

$$A = \frac{1 - \beta}{\alpha} = \frac{0.90}{0.05} = 18$$ $$B = \frac{\beta}{1 - \alpha} = \frac{0.10}{0.95} \approx 0.1053$$

Boundary Line Equations in the $(n, y)$ Plane

For a binomial distribution, the log-likelihood ratio simplifies into linear functions of $y$ (number of defects) and $n$ (total samples):

Upper line (reject $H_0$): $$y = h_a + s \times n$$ $$h_a = \frac{\ln A}{\ln\left[\frac{p_1(1-p_0)}{p_0(1-p_1)}\right]} \approx \frac{2.89}{1.26} \approx 2.29$$ $$s = \frac{\ln\left(\frac{1-p_1}{1-p_0}\right)}{\ln\left[\frac{p_1(1-p_0)}{p_0(1-p_1)}\right]} \approx \frac{-0.105}{1.26} \approx -0.083$$

Lower line (accept $H_0$): $$y = h_b + s \times n \quad (\text{identical slope } s \text{ — parallel lines!})$$ $$h_b = \frac{\ln B}{\ln\left[\frac{p_1(1-p_0)}{p_0(1-p_1)}\right]} \approx \frac{-2.25}{1.26} \approx -1.79$$

[IMAGE: "parallel-boundaries-binomial" | style: "chart" | alt: "Two parallel boundary lines in the (n, y) plane for binomial SPRT: upper line rejects H0, lower line accepts H0"]

Implementation Algorithm

  1. Initialize $n = 0, y = 0$.
  2. Sample 1 unit, inspect for defects $\rightarrow$ update $n, y$.
  3. If $y \ge h_a + s \times n \rightarrow$ Reject $H_0$ (process out of control).
  4. If $y \le h_b + s \times n \rightarrow$ Accept $H_0$ (process in control).
  5. If in between $\rightarrow$ Continue sampling (return to step 2).

Full implementation reference: [INTERNAL-LINK: "implementasi-sprt-python-r"]

When to Use SPRT vs. Alternatives?

Scenario Recommendation
Simple vs. simple hypotheses (specific $\theta_0$ vs. $\theta_1$) ✅ SPRT is optimal (Wald & Wolfowitz 1948)
Composite hypotheses ($\theta \le \theta_0$ vs. $\theta \ge \theta_1$) Use truncated SPRT or CUSUM
Need a guaranteed maximum sample size Truncated SPRT (add an $N_{\max}$ boundary)
Prior information is available Bayesian sequential testing (sequential Bayes Factor)
Continuous monitoring (no endpoint) CUSUM / EWMA control charts
Non-i.i.d. data (time series, dependencies) Modified SPRT or Generalized Likelihood Ratio (GLR)

Advantages of SPRT: Maximum sample efficiency, automated stopping rule, strict error control. Limitations: Designed strictly for simple hypotheses, requires strict i.i.d. assumptions, sensitive to model misspecification.

FAQ: Common Questions About SPRT Boundary Functions

Is a 'deviation function' the same as a 'boundary function'?

Yes. In certain regional literature (such as the 2012 UNY dissertation), deviation function (fungsi deviasi) refers to the decision boundary function that defines the threshold deviation of the log-likelihood ratio from the continuation region. Standard international terms include stopping boundaries, decision boundaries, or threshold functions.

Why must there be two boundaries (upper and lower) instead of just one?

Because SPRT tests two mutually exclusive hypotheses ($H_0$ vs. $H_1$). A single boundary can only control one type of error (e.g., Type I only). Two boundaries are required to control both $\alpha$ and $\beta$ simultaneously — a direct consequence of the sequential version of the Neyman-Pearson lemma.

What is the difference between a 'boundary function' and the 'Operating Characteristic (OC) function'?

  • Boundary function: The decision rule established before data collection — dictates when to stop.
  • OC function: The performance curve evaluated after boundaries are set — shows the probability of accepting $H_0$ across all possible true parameter values. Boundary functions DETERMINE the shape of the OC curve.

Does SPRT always terminate?

Yes. [STAT: sprt-termination, tier 1, 1947] — Wald proved that $P_\theta(N < \infty) = 1$ for all $\theta$. A random walk with non-zero drift is guaranteed to hit one of the boundaries in finite time with probability $1$. This is proven via Wald's Fundamental Identity and Stein's Lemma.

What happens if $\alpha$ and $\beta$ are very small (e.g., $0.001$)?

Boundary $A$ becomes very large and $B$ becomes very small $\rightarrow$ the continuation region widens $\rightarrow$ ASN increases drastically. For extreme $\alpha$ and $\beta$ values, consider a truncated SPRT with $N_{\max}$ or switch to a Bayesian sequential design.

  • [INTERNAL-LINK: "derivasi-lengkap-wald-sprt-bukti-matematis"] — Complete derivation of Wald's inequalities using change of measure
  • [INTERNAL-LINK: "implementasi-sprt-python-r-kode-lengkap"] — Ready-to-use Python (statsmodels) and R (SPRT package) code
  • [INTERNAL-LINK: "perbandingan-sprt-vs-fixed-sample-test"] — Comparison table of sample efficiency, power, and ASN
  • [INTERNAL-LINK: "truncated-sprt-cusum-bayesian-sequential"] — Alternatives when standard SPRT does not fit
  • [EXTERNAL-LINK: "https://python.quantecon.org/wald_friedman.html"] — QuantEcon: Interactive SPRT tutorial in Python (Sargent & Stachurski)
  • [EXTERNAL-LINK: "https://openstemlibrary.com/hypothesis-testing-and-nonparametric-methods-chapter-5"] — OpenSTEM Library: Full SPRT chapter with formal proofs
  • [EXTERNAL-LINK: "https://mattlapa.com/sprt/"] — Matt Lapa: Accessible derivation with step-by-step visualizations

Synchronised clock

Current time

.000

UTC

Your time zone

.000

UTC · The same synchronised instant, shown in your time zone.

Server clock (NTP), measuring your network latency…

Round-trip latency
—
Browser clock correction
—
Estimated accuracy
—
Time source
time.google.com (stratum 1)
Server NTP offset
—

Reference interval

00:00:00.000

Hold interval reading

start stop

How to read this clock

The time comes from an NTP server (stratum 1 or 2 is a network of caesium and GPS clocks). On page load the browser measures the round trip to this server and applies half of it as a correction for transmission delay. After that the value is advanced locally, and JavaScript timers drift less than a millisecond per minute under normal conditions.

Use this as the time base instead of a frequency counter: film the screen together with the device under test, then read the interval from the start and stop frames. The same NTP offset applies to both ends, so it cancels in the difference; what remains is the hold quantisation above plus network jitter at the moment of sampling.