SStatistics, Built

Stage V · PhD Research

Part 58 of 65

Anytime-Valid Inference and Adaptive Experiments

PhDstarts at this level74 min of film16 chaptersprerequisites: Part 35, Part 44, Part 46

What if you look at the data every day, and choose what to collect as you go?

At the Statistical Research Group at Columbia in 1943 a Navy officer complains that a test runs its full length long after the answer is clear, and Abraham Wald answers with the sequential probability ratio test. For a defective rate of 10% against 20% the SPRT, computed exactly on its lattice, needs 57 and 59 shells on average where the fixed test needs 109; the unplanned way to look early, a 5% z-test checked after every observation, rejects a true null 38% of the time within 100 looks. The part rebuilds testing so that looking is free. Group-sequential boundaries are placed in the Brownian picture; Ville's inequality, proved by optional stopping, turns any nonnegative martingale into a test valid at every look; betting gives e-values, calibrators and merging, universal inference handles composite nulls, and inverting the tests gives the confidence sequences of the confidence funnel. CAST's deaths are replayed as a betting test, e-BH controls the FDR under any dependence, and CUSUM finds the Nile's change. The part then turns to data collected adaptively: Thompson sampling and the Lai-Robbins bound, the bias of sample means after a bandit, adaptively weighted estimates, and off-policy evaluation, and it ends with five open problems.

What you need. Stages I to IV of the series: likelihood ratios and Neyman-Pearson (Part 46), martingales, optional stopping and Brownian motion (Part 44), group-sequential trials as a recipe (Part 35), and Part 33's Benjamini-Hochberg procedure.

Hook
Wald's SPRT, 1943
Mathematics
the SPRT, alpha spending, test martingales, e-values, composite nulls, confidence sequences, game-theoretic probability, e-BH, change points, bandits and off-policy inference
Built
statkit.sequential

What you will be able to do

Bachelor's

  • Explain why checking a 5% test after every observation is not a 5% test, and read the peeking curve.
  • Follow a bettor's wealth through the CAST deaths and say what a wealth of 20 licenses.

Master's

  • Derive Wald's thresholds and error bounds for the SPRT, and compute its expected sample size by Wald's identity.
  • Prove Ville's inequality by optional stopping and turn a likelihood-ratio martingale into an anytime-valid p-value.
  • Derive Robbins's normal-mixture confidence sequence.

PhD

  • Prove that e-BH controls the FDR under arbitrary dependence, and state why the average of e-values is an e-value while the product needs sequential validity.
  • State the GROW criterion and the reverse information projection for a composite null, and the cost of universal inference against the t-test.
  • State the Lai-Robbins lower bound and explain why sample means after adaptive allocation are biased and not asymptotically normal without reweighting.

Practice

  • Monitor an experiment that will be looked at daily with a confidence sequence or a group-sequential boundary, and report an estimate corrected for the stop.
  • Set a CUSUM threshold from a target false-alarm run length and state the detection delay it buys.
  • Record the assignment propensities of an adaptive experiment so that weighted and off-policy estimates can be computed afterwards.

Contents

Each chapter has a home level. Choose a track to see what to read and watch: Bachelor's 10 min · Master's 25 min · PhD 74 min · Practice 25 min.

  1. 0The Statistical Research Group, 1943Bachelor's4 min
  2. 1The SPRTPhD6 min
  3. 2Group-sequential theoryPractice5 min
  4. 3Test martingales and VillePhD5 min
  5. 4Testing by bettingPhD6 min
  6. 5Composite nullsPhD5 min
  7. 6Confidence sequencesPhD6 min
  8. 7CAST as a betting testBachelor's4 min
  9. 8Game-theoretic probabilityPhD5 min
  10. 9Multiple testing with e-valuesPhD4 min
  11. 10Change detectionPractice6 min
  12. 11Bandits and adaptive designsPractice5 min
  13. 12Inference after adaptivityPhD5 min
  14. 13Off-policy evaluationPhD4 min
  15. 14Open problemsPhD4 min
  16. Recap, problems, and the road aheadAll tracks2 min

Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · Build the film.

Lecture

The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film. A dashed box stands for a number the film computes when it is rendered (hover over it to see what is computed); the README's figures for each chapter, where it lists them, follow the chapter's text.

The Statistical Research Group, 1943Bachelor's4 min

In 1943, at the Statistical Research Group at Columbia University, a Navy officer complained about a test comparing two alternative methods. It had to run its full planned length, though a seasoned observer could have called the answer long before. W. Allen Wallis and Milton Friedman wondered whether a test could stop as soon as the evidence sufficed, and took the question to Abraham Wald. Wald's answer was the sequential probability ratio test. It was classified until 1945, then published, and in 1947 became a book. Wallis, writing the group's history in 1980, counted it among the most seminal statistical ideas of its time.

The idea fits in one line. After each observation, compute the likelihood ratio of the alternative against the null. If it climbs above a threshold A, stop and reject the null. If it falls below a threshold B, stop and accept it. Otherwise take another observation. Wald showed that A equal to one minus beta over alpha, and B equal to beta over one minus alpha, are approximate target thresholds. Overshoot changes actual errors; we compute them for this IID example.

Wald's own kind of example: lots of shells, where a defective rate of ten percent is acceptable and twenty percent is not, with alpha five percent and beta ten. The smallest nonrandomized one-sided binomial count test meeting these targets needs shells, rejecting with or more defectives. The sequential test, computed exactly, needs on average shells when the rate is ten percent and when it is twenty: a saving of about percent, with its error rates at and percent, inside the targets.

But the SPRT is the disciplined way to look early. The undisciplined way is to run an ordinary five percent test, and check it after every new observation. If there is no effect at all, the chance of having rejected somewhere within a hundred looks is percent; within five thousand, percent, and it goes to one. The law of the iterated logarithm guarantees it: a random walk crosses every fixed multiple of root n infinitely often.

So there are two questions. The first is how to test so that you may look whenever you like, and stop whenever you like, and keep your error rate. The answer will be a single inequality from 1939, Jean Ville's, and the idea of betting against the null. The second is how to experiment when you choose what to collect as you go, as an A/B platform or an adaptive trial does. Then the data are no longer independent of the design, and inference needs its own tools.

Two promises come due. Part ten computed a p-value once, at a sample size fixed in advance, and assumed you look once. Chapters three to seven build e-values and test martingales, valid at every look. Part thirty-five gave group-sequential boundaries for looks planned in advance. Chapter two puts them in the Brownian picture, and chapter six allows a look at any time.

Numbers: p₀ = 0.1, p₁ = 0.2, α = 5%, β = 10%: fixed test n = 109 (reject at ≥ 17); SPRT E N = 56.9 and 59.3, errors 3.9% and 9.7%; peeking: 38% by 100 looks, 62% by 5,000

1The SPRTPhD6 min

The sequential probability ratio test: how it works, what it costs, and why nothing does better.

For Bernoulli data the log likelihood ratio is a random walk. Each defective adds the log of p one over p nought, here . Each good shell adds the log of one minus p one over one minus p nought, here minus . The walk stops when it leaves the band between log B, minus , and log A, . Because the steps take only two values, the walk lives on a lattice: after n shells with s defectives it sits at s a plus n minus s times b. So the probability of every way to stop can be computed to controlled numerical precision with a bounded remainder, by pushing the probabilities of the states still inside the band forward one shell at a time.

Here are twelve lots at each rate. The band runs from log B up to log A. At a defective rate of ten percent, the walks drift down, because good shells dominate; of the twelve are accepted, after shells on average. At twenty percent, the walks drift up; of the twelve are rejected, after shells on average. Each walk stops the moment it leaves the band: no shell is tested after the evidence is in.

On the event that the SPRT rejects, its likelihood ratio at stopping is at least A. Changing measure shows that the alternative rejection probability is at least A times the null rejection probability. Therefore the size is at most one over A, or alpha divided by one minus beta for Wald's approximate thresholds. Similarly, the other error is at most beta divided by one minus alpha. The stricter nominal targets are not automatically guaranteed. For this Bernoulli example we compute the actual errors by lattice propagation, including overshoot.

Wald's identity assumes IID integrable increments and a stopping time with finite expected length. Then the expected stopped sum equals the mean increment times expected length. At an SPRT stop the sum is near one of the boundaries, with an overshoot. Ignoring that overshoot approximates expected length by expected boundary position divided by the drift, except at zero drift where a limit is needed. Under the two specified hypotheses the drift is respectively a negative and a positive Kullback-Leibler divergence. At an intermediate true rate it is simply the expected log likelihood increment.

The whole operating characteristic, exactly. On the left, the probability of rejecting the lot as the true rate varies; on the right, the average number of shells. In blue, the exact values; in grey, Wald's approximations, which ignore the overshoot and are close. The average sample size is largest between the two hypotheses, about near a rate of , where the data cannot make up their mind; it is still below the fixed test's , shown in red.

The saving is on average. The number of shells is random, and sometimes large: at a rate of ten percent, the sequential test runs past the fixed test's shells percent of the time, and at twenty percent, percent. In practice the test is truncated: decide at a maximum sample size if the walk is still inside. A terminal rule must be calibrated jointly with the boundaries: truncating and deciding by sign can change error rates substantially. A guaranteed budget requires a new error calculation.

And nothing does better. Abraham Wald and Jacob Wolfowitz proved in 1948 that for IID observations from two simple hypotheses, among tests with finite expected lengths, sequential or not, whose two error probabilities are no larger than the SPRT's, none has a smaller expected sample size under the null, or under the alternative: the SPRT minimizes both at once. The proof is Bayesian: the SPRT is the Bayes rule for a prior on the two hypotheses and a cost per observation, an argument Part forty-five's decision theory makes natural. Between the two hypotheses, though, other tests can do better, which is why later work truncates and adapts.

A worked check on overshoot. The target errors were five and ten percent; Wald's bounds allow up to and percent. The exact errors are and percent. The size is below five percent because a defective is a big step, log two, so the walk usually jumps well past log A when it crosses. Siegmund's renewal theory corrects the thresholds for the expected overshoot, and recovers the targets almost exactly.

Numbers: steps +0.693 per defective, −0.118 per good; band (−2.25, 2.89); 12 lots each: mean 43 and 60 shells; ASN peaks at 88.6 near p = 0.15 (Wald 79.4); P(N > 109) = 9.3% and 11.7%

2Group-sequential theoryPractice5 min

Group-sequential theory: a few planned looks, in the Brownian picture, and what stopping does to an estimate.

Group-sequential designs inspect a trial at a sequence of information fractions. The illustrated calculation uses five equally spaced looks. For independent Gaussian observations with known variance, the scaled score has exactly the Brownian joint law at deterministic information times. Other settings often use this as an approximation. Propagate the surviving density between looks and remove probability crossing either boundary. Smooth quadrature on the continuation interval avoids a grid that rounds moving boundaries. Exactness refers to this Gaussian model and the stated timing design, not arbitrary looks chosen from the current z statistic.

Two classical boundaries for five looks at overall level five percent, two-sided. Pocock's is flat: reject at any look where the absolute z statistic exceeds . O'Brien and Fleming's starts high, at the first look, and falls to at the last, close to the fixed test's one point nine six. Pocock stops early more often; O'Brien–Fleming keeps almost all the final test's power, which is why boundaries of the O'Brien–Fleming type are the common choice in practice.

Lan-DeMets spending allows flexibility in analysis timing through a prechosen nondecreasing cumulative error budget. At each information time, solve a boundary using the probability increment spent since the previous look. Timing must be noninformative for the score process or explicitly accounted for in its joint calibration. The displayed O'Brien-Fleming-like spending family is one valid choice, spending little early. Our algorithm illustrates finitely many looks with known information fractions. This is not a fundamental prohibition on all continuous-time spending methods. Confidence sequences offer a different construction for monitoring at every time.

What does stopping do to the estimate? Five O'Brien–Fleming looks, observations each, and the sample mean reported when the trial stops. Overall, the bias is small on these five effect values, with a simulated maximum of standard deviations. But given that the trial stopped early for a positive crossing, it is large: at a true effect of a tenth, , more than doubling the effect. Only percent of such trials stop early, and those that do were lucky: early stopping for benefit selects overestimates, Part fifty-six's winner's curse again.

Stopping selects on the estimates. In our two-sided trial, an early positive crossing selects high estimates; an early negative crossing selects low ones. The gold curve conditions specifically on a positive early crossing. Its upward bias can greatly exceed the overall bias. The overall mean also averages continuations and negative crossings, and can show partial cancellation. The five simulated effect values do not establish a uniform bound over all effects. This is why an estimate reported after a particular type of stop needs a stopping-aware analysis. Pooling selected early efficacy stops can inherit the same selection problem.

The remedies come from ordering the sample space. Order outcomes by the look at which the trial stopped, then by the statistic: stagewise ordering. A p-value is the probability of an outcome at least as extreme in that order, computed with the same Brownian recursion. Inverting it in theta gives a confidence interval, and solving its stagewise one-sided p-value equation at one-half gives a median-unbiased point estimate. That estimate need not be the interval midpoint. These are the standard tools in Jennison and Turnbull's book, and they assume, again, that the looks and the stopping rule were followed exactly.

Where this leaves us. Group-sequential designs are exact, efficient, and accepted by regulators. But they need the looks, or at least a spending plan, fixed in advance, and a known maximum information. Online platforms look continuously, stop for business reasons, and add data without plan. For them we need guarantees that hold at every time at once, which is the next chapter's subject.

Numbers: K = 5: Pocock 2.413; O'Brien–Fleming 4.56, 3.23, 2.63, 2.28, 2.04; maximum observed overall bias on five effects ≈ 0.023 SD, but about 0.14 given a positive early stop at θ = 0.1 (16% stop early)

3Test martingales and VillePhD5 min

Test martingales and Ville's inequality: one line of 1939 that makes peeking safe. A test martingale for a null hypothesis is a process M t with three properties. It starts at one. It is never negative. And under the null, it is a martingale: its expected next value, given everything so far, is its current value. The likelihood ratio of any alternative against a simple null is one: Part forty-four met it as the wealth of a gambler betting against the null at fair odds.

Jean Ville proved in 1939 that a nonnegative martingale starting at one rarely gets large, at any time at all: the probability that it ever reaches one over alpha is at most alpha. That is Markov's inequality, but for the whole path at once rather than one fixed time. So the test that rejects the null the first time the martingale reaches twenty has type-one error at most five percent, however long you watch, and however you decide to stop.

Stop at the first threshold crossing, or at a fixed horizon T if there is none. This is a bounded stopping time. Optional stopping gives expected stopped wealth one for a test martingale, and at most one for a nonnegative supermartingale. At a crossing, stopped wealth is at least one over alpha. Elsewhere it is nonnegative. Thus the crossing probability is at most alpha. Increase T without limit. The crossing events increase to the event of ever crossing, proving Ville's inequality.

The two tests, side by side, on twenty thousand null streams. In red, the ordinary five percent z-test, checked after every observation. Its chance of a false rejection climbs: percent by a hundred looks, percent by five thousand. In gold, the test that rejects when a likelihood-ratio martingale reaches twenty, watched for a thousand observations: percent. Below the promised five percent, as Ville said, however often we looked.

The same story as wealth. A gambler bets that the mean is point three rather than zero, multiplying her capital by the likelihood ratio at each observation. On forty null streams the wealth decays towards zero: betting against a true null loses. A few paths touch twenty on the way, of these forty; those are the false alarms, and Ville caps their population crossing probability at five percent; forty paths have sampling variation. When the mean really is point three, wealth grows exponentially, and it crosses twenty eventually almost surely under this IID alternative; individual waiting times vary.

The SPRT's likelihood ratio is a test martingale under its simple null. Ville bounds the chance of ever reaching A by one over A, the relaxed error bound from chapter one. We can also dispense with the lower boundary. For size alpha, use the upper boundary one over alpha. Under IID observations from the specified alternative, with positive finite log-likelihood drift, wealth eventually crosses that boundary almost surely. This is a power-one test: it can continue forever under the null.

A stopping rule can depend on the evidence so far, on a budget, or on a manager's request, provided it is a stopping time for the filtration in which the process is valid. At any almost surely finite stopping time, a nonnegative test supermartingale has expected stopped wealth at most one. Consequently, the minimum of one and its reciprocal is a valid p-value at that stop. More data preserve the error guarantee, though wealth can fall. The bets must be chosen before the outcomes to which they apply. Future information cannot be used to choose today's stake.

Include the starting wealth of one, and take the reciprocal of the largest wealth seen so far. This gives an anytime-valid p-value. Ville bounds the probability that it ever falls below alpha by alpha. An ordinary fixed-sample p-value generally lacks this guarantee when repeatedly inspected. A chosen sequential procedure may sacrifice power at some sample sizes to work well at others. There is no universal strict power penalty at every fixed time: one can always wait for a chosen fixed-sample test. The challenge is to distribute power across possible stopping times.

Numbers: 20,000 null streams: Ville's test (M ≥ 20, 1,000 looks) 4.1%; peeking 53% by 1,000 looks

4Testing by bettingPhD6 min

Testing by betting: e-values, how to calibrate them, how to merge them, and how to bet well.

Glenn Shafer proposed in 2021 that a test should be read as a bet. To test a hypothesis, offer a bet that costs one unit and has expected payoff at most one if the hypothesis is true. Its payoff, once the data arrive, measures the evidence: a payoff of twenty means the bet multiplied your money twenty-fold. A series of such bets, each staking the winnings of the last, is a nonnegative test supermartingale when each factor has conditional expectation at most one. The language changes what a result means: not a rare event under the null, but money won by betting against it.

The payoff is an e-value: a nonnegative random variable whose expectation under the null is at most one. By Markov's inequality, the chance that it reaches one over alpha is at most alpha, so one over e is a valid p-value. The converse needs a calibrator: a decreasing function f with integral one over the unit interval turns any p-value into an e-value. Vladimir Vovk and Ruodu Wang's family, kappa p to the kappa minus one, is the standard choice.

What p-values are worth as e-values. With kappa a half, a p-value of five percent becomes an e-value of ; one in a thousand becomes . With kappa a tenth, small p-values gain more and large ones less. One over p is not an universally valid e-value: its expectation is infinite for a uniform null p-value. Calibrated e-values grow much more slowly, a stricter currency. For the chosen half-power calibrator, five percent maps to about two. Another prechosen calibrator gives a different payoff; this is not a universal evidence value or posterior odds.

E-values combine easily. The average of e-values is an e-value, whatever their dependence, because expectation is linear. The product of independent e-values is an e-value, and so is the product of sequential ones, each valid given the past: that is how a test martingale is built. P-values combine with difficulty: Fisher's method needs independence, and under arbitrary dependence valid rules, such as Bonferroni or twice the average p-value, pay a penalty. So e-values are the natural currency for evidence that accumulates across studies, sites or time, as in meta-analysis done as the studies arrive.

An illustration. Five independent studies of twenty observations each, a true effect of point four standard deviations, and each study's e-value the likelihood ratio for an effect of a half. A single study reaches twenty percent of the time. The average of the five, valid under any dependence, reaches twenty percent of the time. The product, valid because they are independent, reaches it percent of the time: evidence multiplies.

How should one bet? Betting b on normal data multiplies wealth by e to the b X minus b squared over two. Its growth rate, the expected log of wealth per observation, is b mu minus b squared over two: three bets, three straight lines in mu. The best growth, mu squared over two, comes from betting exactly the true mean. And overbetting is worse than underbetting: bet one when the mean is a quarter, and wealth shrinks even though the null is false.

Validity asks whether the bet is fair under the null. Efficiency asks how rapidly wealth grows under an alternative. Kelly's criterion maximizes expected log wealth. For a simple null and a specified alternative, the likelihood ratio is log optimal. A predictable fitted alternative also gives fair likelihood-ratio factors when each candidate is a proper density. In the unit-variance normal example, betting on mean b when the truth is mu gives growth b mu minus b squared over two. It is maximized at b equal to mu. The growth loss is half the squared betting error, symmetric for equal overestimates and underestimates. A very oversized bet can lose money even under the alternative. Composite nulls require fairness against every null member.

A p-value describes a tail probability under a null model; an e-value is a nonnegative payoff with null expectation at most one. Both can support valid tests. Fixed-sample e-values are convenient to average, while independent or conditionally fair factors can be multiplied. A collection of e-values valid at separate fixed times is not automatically an e-process. Validity at stopping times needs an additional sequential construction. Likewise, anytime-valid p-values are possible. The practical distinction is the guarantee of the particular construction, rather than the letter used to report evidence.

Numbers: p = 0.05 → e = 2.24 (κ = ½), p = 0.001 → 15.8; five studies: P(E ≥ 20) 26% (one), 46% (average), 82% (product)

5Composite nullsPhD5 min

Composite nulls: when the null hypothesis is a family, how can a bet be fair against all of it?

So far the null was simple: one distribution. Most nulls are composite: a normal mean of zero with unknown variance, or independence of two variables. An e-value must then have expectation at most one under every distribution in the null at once. A likelihood ratio against one member of the null is not enough: under another member it can have expectation far above one. Two answers have emerged: universal inference, valid with correct split likelihoods, and the growth-optimal e-values of safe testing, which are efficient.

Universal inference begins with independent training and evaluation halves from a correctly specified IID model. It needs normalized likelihoods, but not a regular asymptotic approximation. Fit any proper alternative density on the training half. On the independent evaluation half, divide its likelihood by the supremum of the null likelihood. That denominator must be the true supremum, or a certified upper bound; a failed optimization can invalidate the guarantee. The result is an e-value for every null member. This is a fixed-sample construction; repeatedly reusing it at new sample sizes does not automatically produce an e-process.

Fix a true null member. The null likelihood supremum is at least its likelihood on the evaluation half. The split ratio is therefore bounded above by a likelihood ratio against that true distribution. Conditional on the independent training half, the fitted alternative is fixed. Its likelihood ratio has expectation at most one, with equality when the alternative is absolutely continuous with respect to the true distribution. Taking expectations proves the e-value guarantee. Averaging a fixed collection of valid split e-values preserves validity and reduces dependence on one random split, without necessarily removing all split randomness.

Universal inference against the t-test, for a normal mean of zero with unknown variance, forty observations. Under the null, the t-test rejects percent of the time and universal inference percent: both valid, the second very conservative. At a mean of a half, the t-test's power is percent, universal inference's only . Validity came free; efficiency did not. The split throws away half the data for fitting, and the split likelihood ratio and Markov threshold are conservative in this example; both tests target five-percent size.

The price can be read off. Universal inference's rejection threshold corresponds roughly to a likelihood-ratio statistic of two log of one over alpha, computed on half the data. In regular problems, where Wilks's chi-squared threshold applies, that makes it clearly less powerful, as the table showed. It is a price worth paying where Wilks fails: mixtures, shape constraints such as log-concavity, and boundaries, where no classical test has a known null distribution. Robin Dunn and colleagues, for example, built from it a practical test of log-concavity.

For a specified alternative Q, maximize expected log payoff among all e-values valid for the null family. This is the simple-alternative version of the growth-optimal criterion; a composite alternative requires a separate worst-case optimization. Under suitable domination, existence and integrability conditions, the solution is q divided by its reverse information projection onto the closed convex null family. The projection may be a mixture, rather than a member of the original null. For suitable invariant problems, including a scale-invariant t-test, the maximal-invariant likelihood ratio has an optimality result. Its stopping guarantee is relative to the maximal-invariant filtration. An arbitrary raw-data stopping rule can invalidate its stopped e-value; the filtration is part of the theorem.

Suppose the reverse information projection exists as a dominating density and the differentiation conditions hold. Perturb that minimizing density toward any density in the convex null family. The nonnegative directional derivative of the Kullback-Leibler objective says that the null expectation of q divided by the projection is at most one. This is precisely the e-value requirement for every original null member. The least favourable comparison can lie in the convex hull rather than the original family. Without an attained projection, a generalized projection theorem is needed; the displayed ratio is not an unconditional existence claim.

Composite nulls require a bet fair against the whole family. Split likelihood ratios give fixed-sample e-values under correct independent evaluation likelihoods, often conservatively. Growth-optimal constructions can exploit structure, but their existence, optimality and filtration assumptions matter. Mixtures preserve a common sequential validity guarantee, and predictable plug-in alternatives work against a simple conditional null. Neither device alone solves an arbitrary composite null. Choose a construction whose assumptions and stopping information match the scientific experiment.

Numbers: n = 40, σ unknown: t-test 4.7% under H₀, universal inference 0.1%; at μ = 0.5, 87% vs 18%

6Confidence sequencesPhD6 min

Confidence sequences: intervals that hold at every time at once, so you may watch them shrink and stop when you like.

A confidence interval covers the parameter with probability one minus alpha at one sample size. A confidence sequence is a sequence of intervals, one for each time, that cover it at all times simultaneously, with probability one minus alpha. So the interval at any stopping time is a valid confidence interval, however the stopping time was chosen. Herbert Robbins and Donald Darling introduced them in 1967, and Robbins built them from mixtures in 1970. One useful construction inverts a family of anytime-valid tests, for example test martingales, one for each candidate value.

Robbins's normal mixture, for standard normal data with mean mu. For each bet lambda, e to the lambda times the centred sum, minus lambda squared t over two, is a test martingale. Average it over lambda drawn from a normal with variance tau squared: still a martingale, with a closed form. Ville says it stays below one over alpha forever with probability one minus alpha. Solving for mu gives the sequence: the running mean, plus or minus a width that shrinks like root of log t over t.

The law of the iterated logarithm describes the fluctuations of a nondegenerate IID centered sum after variance normalization. For ordinary intervals centered on the sample mean, this prevents an eventual half-width smaller than the iterated-logarithm scale. It is not a pointwise lower bound on every imaginable confidence sequence. Stitching boundaries over geometric epochs attains this rate with explicit constants. The fixed normal mixture instead has a root log t factor. The displayed one-sided stitched bound applies to conditionally one-sub-Gaussian centered increments. For bounded zero-to-one data, one-half is a valid sub-Gaussian scale.

The confidence funnel, this part's instrument, on one stream from the World's A/B platform: visitors convert with probability twelve percent, and time runs on a log scale. In red, the ordinary ninety-five percent interval recomputed at each visitor. The red dots mark the times it excluded the truth: of the times drawn. Anyone stopping at one of them would have reported a wrong interval. In blue, Robbins's mixture sequence; in green, the betting sequence of the next ladder. For these Bernoulli data the normal mixture uses the Hoeffding sub-Gaussian scale one-half, giving a supermartingale rather than an exact Gaussian martingale. Both bands contain the truth throughout on this stream. The price: at five thousand visitors the betting sequence is plus or minus points, against for the fixed interval.

Betting confidence sequences need bounded observations and a common conditional mean: the next observation's expectation given the past is mu. Marginal boundedness alone does not suffice. At the true candidate mean, one plus a predictable stake times the centered observation has conditional expectation one. Cap the stake to keep every factor nonnegative. Our predictable plug-in stakes use past variance, with separate upward and downward gamblers. This illustrative rule is not claimed to attain the optimal iterated-logarithm rate. We keep the running intersection of candidates whose hedged wealth has not crossed. Numerically we exclude whole grid cells only using a lower wealth bound, then return an outer interval. This preserves continuum coverage, including means between grid nodes and the endpoints.

Over streams, watched from the twentieth visitor to the two-thousandth. The CLT interval covers at the end percent of the time, as expected approximately at this fixed sample size, but throughout only percent. The two confidence sequences hold throughout: the mixture percent, the betting sequence . Hoeffding's fixed interval also survives here, but only because it ignores the variance and is far too wide for a rate of twelve percent: lucky, not valid.

The cost, in width, at five thousand visitors, in percentage points either side. The fixed CLT interval: . The betting sequence: , about times wider. Robbins's mixture: ; the stitched boundary: . And a union bound over Hoeffding intervals, the naive way to make them hold at all times: . Here variance adaptation gives the narrowest displayed sequence. The factor of about two is specific to this sample size and path. Relative to a fixed-sample interval, even an iterated-logarithm width factor can grow slowly without bound.

What to take away. A confidence sequence can be built by inverting anytime-valid tests: test every candidate value, keep those not yet rejected. It may be watched continuously, stopped at any time, and extended with more data, keeping its coverage. Its width can approach the law of the iterated logarithm's limit, and adapts to the variance when built by betting. And online experimentation platforms have adopted always-valid inference, as Ramesh Johari and colleagues argued they should, because their users look every day.

Numbers: 300 streams, t ∈ [20, 2,000]: CLT 46.3% uniform (94% at the end), mixture 100%, betting 97.0%; widths at 5,000: CLT ±0.91, betting ±1.85, mixture ±2.38, stitched ±2.96, union Hoeffding ±4.61 points

7CAST as a betting testBachelor's4 min

A real trial as a betting test: CAST, which was stopped early because its drugs were killing patients.

The Cardiac Arrhythmia Suppression Trial. After a heart attack, irregular beats predict sudden death, and the drugs encainide and flecainide suppress them. The trial randomized patients whose arrhythmias the drugs had suppressed, to the drug or to placebo. Its monitoring board stopped those arms early, in 1989; the final report counted deaths on the drugs against on placebo. Suppressing the surrogate had not saved lives; it had cost them. Part thirty-five told the story of the surrogate. Here we ask how the evidence accumulated.

The extract gives aggregate deaths, not individual risk sets, follow-up times, or their sequence. We illustrate a working model in which successive death labels are IID fair coins under the null. Nearly equal trial arms do not by themselves justify that model. Mix alternative death-label probabilities uniformly between zero and one. After s drug labels among n deaths, the mixture likelihood ratio is two to the n times the Beta function of s plus one and n minus s plus one. It is a test martingale under this working label model. At the recorded totals, sixty-three of eighty-nine deaths, the terminal wealth is about three hundred and thirty-three. This does not reconstruct the clinical trial's sequential analysis.

The actual death order is unavailable in our extract. We simulate two thousand orders conditional on the final totals. Thirty are shown; these are illustrative paths, not recovered patient histories. Across the two thousand simulated orders, the median first crossing of wealth twenty is forty-five deaths. The tenth to ninetieth percentiles describe those random permutations only. They do not establish when the actual monitoring board could have acted. Every ordering ends at the same wealth, about three hundred and thirty-three. Its reciprocal bounds the anytime p-value under the working fair-label model; an actual running maximum requires the actual sequence.

A normal approximation to a fixed-size fair-label count gives z about three point nine two for sixty-three of eighty-nine labels. This is not the original clinical trial's two-arm analysis. Under the same illustrative label model, terminal mixture wealth is about three hundred and thirty-three; its reciprocal is about point zero zero three. The count test is a fixed-n comparison, while a properly specified mixture process permits monitoring over time. The difference here reflects both construction and monitoring, and is not a universal loss of power for e-values. A clinical guarantee would need the trial's randomization, evolving exposures and risk sets. The aggregate totals alone do not supply them.

CAST demonstrates the importance of mortality endpoints and safety monitoring. The aggregate totals also support an illustrative betting calculation under an explicit working model, but the simulated paths cannot locate the actual earliest warning. Monitoring boards need sequential methods matched to the trial's assignment and outcome processes. The central clinical lesson remains: improvement in a surrogate did not establish improved survival. A sequential method cannot repair a scientifically inappropriate endpoint.

Numbers: 63 of 89 deaths on the drugs: mixture wealth 333 (anytime p ≤ 0.003; fixed z = 3.92, p ≈ 9 × 10⁻⁵); over random orders wealth reaches 20 after a median of 45 deaths (10%–90%: 16–71)

8Game-theoretic probabilityPhD5 min

Game-theoretic probability: Shafer and Vovk's foundation, in which probability itself is defined by betting.

Glenn Shafer and Vladimir Vovk rebuilt probability as a game between three players. At each round, Forecaster announces prices for bets on the next outcome. Skeptic chooses a bet at those prices, and may not risk more than she has. Reality announces the outcome, and Skeptic's capital changes accordingly. No probability distribution is assumed anywhere: Reality may play however it likes, adversarially even. Probability is what Skeptic cannot profit from.

Upper probability is the least starting capital needed for a nonnegative strategy to cover an event indicator. In a complete finite-horizon binary forecasting game, backward replication makes this price equal to the probability from the announced conditional forecasts. More general infinite-horizon equalities require additional assumptions. A game-null event admits nonnegative strategies that become arbitrarily rich on it; a savings construction can turn repeated gains into unbounded banked capital. This gives a pathwise language for almost-sure laws. A frequentist probability guarantee still refers to a probability model for which the bets are conditionally fair.

Suppose binary forecasts are always one-half, but the running frequency fails to converge to one-half. Divide capital among a countable collection of gamblers with fixed small positive and negative rational stakes, all chosen before the observations. The logarithm of each account is bounded below by its stake times the centered sum minus a quadratic stake cost. If a nonzero excess frequency recurs, one correctly signed small stake has arbitrarily large capital along that subsequence. A standard banking or savings strategy locks in these recurring gains. Thus a single combined nonnegative strategy can become rich whenever the strong law fails. An informal rule that simply bets on whichever side was recently winning is not the proof.

For a probabilistic test of a weather forecaster, state the null precisely: conditional on the full observed past, the next rain probability equals the announced forecast. Empirical calibration alone is weaker. Choose a nonnegative predictable betting factor using that forecast before rain is observed. Under this conditional forecasting null the capital is a test martingale. Ville then bounds the chance of ever reaching one hundred by one percent under that null. Capital can be computed for any weather sequence, but the probability statement depends on the conditional null being true.

A forecaster always announces thirty percent. For a worked alternative, suppose rain is IID with probability forty percent. A stake of one-half multiplies capital by one point three five on rain, and point eight five otherwise. Expected log growth is point four log one point three five plus point six log point eight five, about point zero two two five per day. Dividing log one hundred by this drift gives about two hundred and four days. This is a drift approximation, not a guaranteed crossing time. Overshoot and random fluctuations matter: under this IID alternative the expected crossing time lies between roughly two hundred and four and two hundred and eighteen days.

An e-value measures the payoff of a test bet, rather than the probability that a hypothesis is true. A sequentially valid betting construction can allow data-dependent stopping without a preplanned sample size. Its null-model or conditional-forecast assumptions remain essential. Evidence multiplies when the next factor has conditional null expectation at most one. Merely choosing a bet before seeing its outcome does not establish that fairness. Shafer advocates this betting interpretation as a useful way for scientists to communicate evidence. That philosophical interpretation is separate from the mathematical assumptions behind the guarantee.

A rough scale, to read e-values. Below one: the bet lost, no evidence against the null. Around ten: worth noticing; a p-value of half a percent, calibrated, is worth about this. Around a hundred: strong, as CAST's evidence of harm was by the end. Beyond a thousand: very strong. This resembles Jeffreys's scale for Bayes factors in Part fifteen, and for simple hypotheses the likelihood ratio is both a Bayes factor and an e-value.

Numbers: a forecaster saying 30% when it rains 40%: growth 0.0225 a day at λ = ½, log-drift crossing approximation about 204 days under IID .4 rain; random waiting time

9Multiple testing with e-valuesPhD4 min

Multiple testing with e-values: false discovery rate control under any dependence, and for experiments that each stop when they like.

Ruodu Wang and Aaditya Ramdas's e-BH procedure. Given e-values for m hypotheses, sort them from largest to smallest. Find the largest k for which the k-th largest e-value is at least m over alpha k. Reject those k hypotheses. It is Benjamini–Hochberg applied to one over the e-values, and it controls the false discovery rate at alpha under any dependence whatever, with no correction factor.

The proof is three lines. A null hypothesis i is rejected only if its e-value is at least m over alpha times the number of rejections R. So its contribution to the false discovery proportion, one over R if rejected, is at most alpha e i over m. Take expectations: each null's e-value has mean at most one. Summing over the nulls gives at most alpha times the number of nulls over m, below alpha. Dependence never entered: only linearity of expectation.

The two procedures on a simulated platform with correlated metrics, of them with real effects. Benjamini–Hochberg on p-values: false discovery rate percent, power percent. e-BH on likelihood-ratio e-values: percent and percent. Both control the rate; e-BH is far more conservative, and pays in power. Here one-sided Gaussian p-values satisfy PRDS, so BH is valid. E-BH allows arbitrary dependence, provided every null input remains a valid e-value for the actual experiment and stopping information.

So when is e-BH the right tool? When the e-values come from sequential tests: each experiment on a platform runs its own test martingale and stops on its own schedule. For stops allowed by each process's filtration, stopped wealth is an e-value. Fix the family and combine those valid inputs by e-BH. When the dependence is unknown and possibly negative, where BH would need the Benjamini–Yekutieli factor, about log m. And when the e-values are not independent of the selection, as with Part fifty-six's derandomized knockoffs, built by averaging e-values from many knockoff draws.

Recent work develops an e-value closure principle for false discovery rate control. The merged paper is by Xu, Solari, Fischer, de Heide, Ramdas and Goeman. Its constructions associate e-values with intersections and use them to permit rejection sets, extending the scope of closed testing. A closed e-BH construction contains the ordinary e-BH rejection set with the same FDR guarantee, and can add discoveries for some inputs. The paper also gives uniform improvements of Benjamini-Yekutieli. These are specific constructions with their own assumptions and computation, not a license to enlarge any rejection set arbitrarily.

A valid platform pipeline must define the hypothesis family and the information available for stopping. An experiment can use a confidence sequence in its valid filtration. Its stopped e-process value is an e-value only for a stopping rule allowed by that filtration. If other experiments influence stopping, joint-filtration validity needs justification. Apply e-BH once to the specified family of valid e-values; arbitrary dependence is allowed. Do not substitute running maxima for e-values, select only successful finished experiments and redefine the family size, or repeatedly report the last significant e-BH set without an additional theorem.

Numbers: 50 metrics, 10 effects of 3 SD, equicorrelation 0.6, q = 0.1: BH FDR 6.7%, power 77%; e-BH 1.0%, 47%

10Change detectionPractice6 min

Change detection: when the question is not whether, but when, something changed. Ewan Page's cumulative sum, from 1954, for a process that may shift from mean mu nought to mu one at an unknown time. Add up the log likelihood ratios, but never let the total fall below zero. While nothing has changed, the increments have negative mean and the sum keeps resetting to zero. After the change they have positive mean, and the sum climbs. Raise the alarm when it crosses a threshold h: a likelihood-ratio scan that restarts whenever its cumulative log increment becomes negative.

Why the reset? The likelihood ratio for a change at time k, against no change, is the product of the increments from k onwards. The best change point is the one that maximizes it: the maximum over k of the sum from k to t. That maximum obeys exactly the CUSUM recursion: either the best change is the old one, extended by one step, or it starts afresh now. So CUSUM is a generalized likelihood-ratio test over the unknown change time, computed in constant memory.

A change detector has two numbers: the average run length to a false alarm when nothing changes, and, in this simulation, delay for a change at the start with zero initial capital. For a one-standard-deviation shift: with h of two, a false alarm every observations and a delay of ; with h of five, a false alarm every , and a delay of . Each unit of h multiplies the time between false alarms by roughly e, and adds a step or two of delay: delay grows only like the log of the false-alarm time.

Lorden evaluates worst-case delay over the change time and the history before it, subject to a lower bound on mean time to false alarm. In the displayed convention, the first post-change observation is at nu plus one. For known IID pre-change and post-change laws, with suitable finite positive information, CUSUM has first-order delay log gamma divided by Kullback-Leibler information. Moustakides proved exact optimality for the calibrated CUSUM in this model and criterion. Arbitrary nominal run lengths can require calibration or boundary randomization. This is a guarantee about a mean run length and a worst-case delay. It is not a bound on the probability of any false alarm over an infinite monitoring horizon.

A real change: the Nile's annual flow at Aswan, a hundred years from 1871. Around 1899 the mean fell, from about to about , in this historical series. The plot alone does not identify a cause. A CUSUM, standardized by the first twenty-eight years and tuned to a drop of one standard deviation, stays near zero, then climbs. It crosses its threshold of four in , two years after the change, and then keeps climbing: the series remains lower over the observed period. This retrospective analysis estimates the baseline from the first twenty-eight years; it is not an exact prospective calibration.

A Bayesian alternative: Ryan Adams and David MacKay's online changepoint detection, from 2007. Track the run length: how long since the last change. Each new observation either extends the current run, with probability one minus the hazard, or starts a new one. The posterior over the run length updates by one line of Bayes's rule, using each run's posterior predictive density. No threshold is needed: the whole posterior is reported, and a change shows as a shift of mass to short runs.

The run-length posterior on the Nile. Each column is a year; the shade shows the posterior mass in two-year run-length bins. Bins below point zero three are omitted, without renormalizing the posterior. The hazard is one in a hundred, and each segment's mean has a normal prior. Until 1898 the mass climbs the diagonal: one long run. Around 1899 it collapses to short runs, and by 1970 the most probable time of the last change is . After that the mass climbs the diagonal again: the fitted model favours a long segment after the earlier change, with uncertainty remaining.

The error criterion matters when comparing change detectors. CUSUM controls mean time to false alarm, with optimal delay in a specified known-law model. Eventual false alarms can still have probability one. Bayesian online detection gives a posterior under chosen segment and hazard models; it does not itself supply a frequentist alarm guarantee. E-detectors aggregate evidence from staggered possible starts to obtain run-length guarantees. For an ever-false-alarm probability bound, one can instead use a prior-weighted mixture of valid start-time processes. An unadjusted maximum over infinitely many starts does not inherit Ville's bound.

Numbers: ARL₀ / delay for a 1-SD shift: h = 2: 36 / 4.5; 3: 117 / 6.6; 4: 345 / 8.2; 5: 871 / 10.3; the Nile: mean 1,098 → 850, CUSUM alarm 1901, posterior-favoured change 1899 under the chosen BOCPD model

11Bandits and adaptive designsPractice5 min

Bandits and adaptive designs: choosing what to collect as the data arrive. William Thompson, in 1933, asked how to allocate patients between two treatments when each patient's outcome is seen before the next arrives. His answer: give each treatment with the posterior probability that it is the better one. Early on, when little is known, that is close to half and half; as evidence accumulates, the better treatment gets more patients. Forgotten for decades, Thompson sampling is now the workhorse of online experimentation, because it earns while it learns.

Exact Bernoulli Thompson sampling keeps a Beta posterior for each arm. A single posterior draw per arm, followed by choosing the largest, samples exactly according to posterior winning probabilities. Our simulations use a distinct finite-Monte-Carlo probability-matching policy: draw a fixed batch of posterior samples, compute winning frequencies, then actually randomize the action using those frequencies. These frequencies are exact assignment probabilities conditional on the auxiliary draws, before the action and response. Update the chosen arm's posterior after observing its response. For inference examples, mix the frequencies with a uniform component so every arm has its stated minimum probability, and record them. Finite-Monte-Carlo matching is an approximation to exact Thompson sampling, not an automatic instance of its asymptotic theorem.

Two page designs on the World's A/B platform, converting and percent of visitors. A balanced test, half and half, loses a conversion for every fifty visitors sent to the worse design, or every hundred visitors overall, in expectation: by four thousand visitors. finite-MC matching loses , because by the end it sends percent of visitors to the better design. That is the earning. The cost, as chapter twelve shows, is in what the data can then tell us.

How few conversions can any policy lose? Tze Leung Lai and Herbert Robbins proved in 1985 that the expected pseudo-regret of uniformly efficient policies across the Bernoulli model class grows at least like log T, with a constant equal to the gap between the arms divided by their Kullback–Leibler divergence. Here, a gap of two points and a divergence of about two thousandths give a constant of : at least log T conversions, asymptotically. Thompson sampling attains that constant, as Emilie Kaufmann, Nathaniel Korda and Rémi Munos showed in 2012, as does KL-UCB. Generic UCB bounds need not attain this sharp constant; our finite-Monte-Carlo approximation is not covered automatically.

A caution about asymptotics. At four thousand visitors, log T is about conversions, more than the balanced test's , and larger than the simulated finite-Monte-Carlo regret. The bound is a statement about T going to infinity; it is not a finite-horizon lower bound, and this argument supplies no numerical crossover time. At realistic horizons, the right comparison is by simulation, as here, or by finite-time bounds.

Some experiments aim to choose a policy after the trial rather than maximize rewards during it. Regret-oriented Thompson sampling still explores worse arms, but its allocation need not optimize final policy choice. Kasy and Sautmann propose exploration sampling, assigning in proportion to posterior best-arm probability times one minus that probability. Their asymptotic analysis concerns their policy-choice criterion and model. For two arms these products are equal, giving balanced allocation. They applied the method to six recruitment strategies for agricultural extension in India. This does not establish universal optimality for every best-arm identification loss or finite horizon.

Three goals pull against each other. Welfare during the experiment: send people to the better arm. Choosing the best arm: keep exploring the contenders. Inference: estimate every arm's effect with an honest interval, which needs every arm sampled enough. And adaptivity can invalidate unadjusted classical intervals, which is the next chapter's problem.

Numbers: 10% vs 12%, 4,000 visitors, 60 runs: balanced loses 40 conversions, Thompson 16 (88% to the better design by the end); Lai–Robbins constant 10, so 10 log T ≈ 83 at T = 4,000

12Inference after adaptivityPhD5 min

Inference after adaptivity: what the data can still tell us when the design chased them.

Adaptive sampling can bias an arm's sample mean. Nie and colleagues prove downward bias for a class of optimistic sampling designs under their conditions; it is not a theorem for every adaptive rule. A poor early outcome can reduce subsequent sampling, leaving that poor start less diluted. A favourable start can attract more observations and be averaged away. This explains the direction in our example, while different stopping and selection rules can produce other biases. Bias alone does not determine coverage. We simulate the actual nominal intervals and report their empirical coverage with Monte Carlo uncertainty.

An arm's sample mean divides its total reward by a random sample count. The count depends on previous rewards. With stationary arm means and predictable assignment, expected total reward is mu times expected count. That identity does not make the ratio unbiased. The count and reward total are generally dependent; a universal sign cannot be read from this equation alone. With known positive conditional assignment probabilities and sequential randomization, the average inverse-propensity score is unbiased. In our finite-Monte-Carlo policy those probabilities condition on the auxiliary posterior draws before action.

A stark case: two arms that are exactly equal, fifty percent each, run by Thompson sampling for a thousand visitors, a thousand times. The arm's sample size swings wildly, from about to visitors, depending on early luck. On the left, the sample means: biased by points and lopsided. On the right, the adaptively weighted estimate of the next ladders: bias points, more tightly concentrated, though still skewed at this size.

Zhang, Janson and Murphy give batched-bandit examples in which the usual estimator and t statistic fail to become normal, even asymptotically. Equal arms are the difficult case in their model. Allocation probabilities need not concentrate at a deterministic limit as batch sizes grow. This is a failure of a stability condition, not a theorem that every equal-arm adaptive design has the same random limiting allocation. The resulting ordinary studentized statistic can have a nonnormal limit and invalidate nominal intervals. Our one-visitor-at-a-time simulation is a separate finite-sample illustration. Their batched OLS combines appropriately studentized batch contributions and is asymptotically normal under the paper's sampling, moment and clipping conditions.

Start from an augmented inverse-propensity score. Predict each arm's stationary mean using past observations. If that arm is selected, add its observed residual divided by its known positive conditional assignment probability. The score has conditional mean equal to the arm's mean, under sequential randomization and the stationary response model. A predictable misspecified prediction still gives an unbiased score. Averaging these scores is unbiased, but small propensities can create large variance. Normality needs a martingale central limit theorem, not just score unbiasedness.

Hadad and colleagues weight the scores predictably, then divide their weighted sum by the sum of weights. This self-normalized estimator can retain finite-sample bias. Square-root propensity weights help stabilize the variance contribution, though they need not make it exactly constant when outcome variance or prediction error changes. The centered weighted numerator is a martingale sum. The ratio itself is not a martingale. Asymptotic normality requires suitable variance stabilization, effective sample growth and Lindeberg conditions. Under those conditions, a consistent studentized spread gives an asymptotically valid interval. It is not an exact finite-sample guarantee for every adaptive design.

Two routes support inference from adaptive experiments under explicit response and assignment assumptions. Weighted AIPW and batched estimators can give asymptotic intervals when their martingale central limit conditions hold. Properly constructed inverse-propensity betting processes can instead give confidence sequences, with known positive propensities and appropriate outcome bounds or moment assumptions. Record the assignment probabilities, including the information used for each randomization. Missing logs obstruct these methods, although other design-specific analyses may sometimes remain possible.

Numbers: finite-MC matching with true 1% floor, two equal arms, 1000 runs: arm A allocation 10%–90% 115–863; naive bias -1.71 points, coverage 90.0%; weighted bias -0.98, coverage 93.7%

13Off-policy evaluationPhD4 min

Off-policy evaluation: what would have happened under a policy we did not run? The adaptive experiment is over, and its logs record, for each visitor, the design shown, the probability of showing it, and the response. A manager asks: what would the conversion rate have been if we had always shown design A? That policy was never run; but every visitor who happened to see A is evidence about it. This is Part thirty-five's potential outcomes question, with a known, changing assignment mechanism.

For a fixed target policy, weight each logged response by target action probability divided by its known conditional logging probability. Under sequential randomization and the stationary outcome model, each score has the target value in conditional expectation. Its mean is unbiased over repetitions of the experiment, not conditional on the complete realized logs. Every action used by the target needs positive logging probability. With contextual policies these probabilities and outcome models must condition on the relevant context. Small overlap can produce large variance. Normal confidence intervals need additional variance and martingale limit conditions.

Add a fixed or predictable model of each arm's mean to obtain an augmented estimator. Predict the target value, then correct it using weighted residuals for the actions actually taken. With the true positive logging probabilities, the estimator remains unbiased even if this predictable model is wrong. A model fitted using the same future responses needs additional justification, such as a suitable independent evaluation design. A good model can reduce variance, but improvement is not automatic for an arbitrary fit. Dudik, Langford and Li developed this approach for bandit policy evaluation in 2011. Our numerical example uses a fixed constant model and asymptotic normal intervals.

On the A/B logs: the policy always show design A, whose true value is . Over runs, inverse-propensity weighting averages , with a standard deviation of , and its intervals cover percent. The doubly robust estimator, with a crude constant model, averages , standard deviation , coverage percent. Both are unbiased; the model's help is small when it knows little, and grows with a better model.

Why did the experiment's floor matter? The weight on a visitor who saw design A is one over the probability of showing A. Thompson sampling drove that probability down as A looked worse; without a floor it can become very small, and a single such visitor would carry a weight of a thousand. The floor of five percent caps every weight at twenty. So an adaptive experiment meant for later evaluation should keep every arm's probability above a floor: a small cost in welfare, a large gain in what the logs can answer.

Where off-policy evaluation is used. Recommendation systems and advertising, to test a new ranking policy on old logs before deploying it. Medicine, to evaluate dynamic treatment regimes from sequentially randomized trials, a subject for Part sixty-two. And reinforcement learning, where the policy acts over many steps and the weights multiply, the hardest case of all.

Numbers: fixed always-A target .10, 200 runs: IPW 0.0991 (SD 0.0156, coverage 92.5%); DR 0.0990 (SD 0.0149, coverage 92.0%); asymptotic normal intervals

14Open problemsPhD4 min

Open problems in anytime-valid inference and adaptive experiments. The part in one table. To stop when the evidence suffices, the SPRT, with calibrated actual errors and optimal expected sample size at its two simple hypotheses. For a few planned looks, spending functions, exact in the known-variance Gaussian model with valid timing. To look at any time, test martingales and Ville's inequality, whatever the stopping rule. For an interval at any time, confidence sequences, covering at all times at once. For many experiments, e-BH, under any dependence. And for adaptive designs, weighted AIPW asymptotically, or inverse-propensity martingales at any time.

A research direction is efficiency for broad composite and nonparametric nulls. Simple-null likelihood ratios and some invariant problems have log-growth optimality results, with their stated alternatives and filtrations. A group symmetry alone is not a universal solution. Valid processes for symmetry and independence are available, as are several efficiency results. What remains problem dependent is how closely practical constructions approach a specified optimality benchmark. A useful project should identify its model, alternatives and loss, then establish a precise gap. It should not claim that the entire efficiency theory is missing.

Another direction is understanding finite-sample reliability of asymptotic anytime-valid inference. Waudby-Smith and colleagues give formal definitions and constructions of asymptotic confidence sequences using time-uniform approximation. Exact sequences can also rely on parametric or conditional-moment assumptions, not only boundedness. Existing theory does not by itself quantify the accuracy for every realistic sample size, dependence pattern or estimated nuisance parameter. A concrete open project can study approximation rates or diagnostics in a specified model. Definitions and an entire process asymptotic theory are not simply absent.

Problem three: designs that serve several goals. Thompson sampling serves welfare, exploration sampling serves the final choice, balanced designs serve inference. Some results characterize the trade-off between regret and estimation error, showing that one cannot have both at their best. But designs that are near-optimal for a stated mixture of goals, with valid inference built in, and practical for real platforms, are open.

Problem four: from theory to regulation. Regulators accept group-sequential designs because their properties are known and their plans are filed in advance. E-processes give stronger guarantees under weaker plans, but the questions a regulator asks, about estimation after stopping, about power, about how a sponsor might game the bets, have only partial answers. Estimation after an anytime-valid stop, and standards for reporting e-values, are open and practical.

Practical extensions include delayed outcomes, interference and changing populations. A delayed conversion may arrive after the next assignment; interference changes the response model; drift can change the estimand. These require revisiting the filtration and conditional means. Delay alone need not invalidate a martingale if only revealed information is used, and existing methods address several such settings. The research challenge is a useful guarantee for a specified combination of these features, rather than a claim that anytime-valid inference for real platforms is wholly undeveloped.

Five open problems. An efficiency theory for e-processes under composite and nonparametric nulls. Finite-sample accuracy of asymptotic anytime-validity. Adaptive designs that serve welfare, choice and inference together. Standards that let regulators accept anytime-valid trials. And inference for platforms with delays, interference and drift.

Recap, problems, and the road aheadAll tracks2 min

Part fifty-eight in twelve lines. The example SPRT uses about half the fixed count test's sample size on average; its optimality compares actual errors at two simple IID hypotheses. Group-sequential designs calibrate planned or validly timed looks, and stopping can bias reported effects. Ville protects nonnegative test supermartingales. E-values average under arbitrary dependence, while products require independence or conditional fairness. Composite nulls need a construction fair against the whole family. Confidence sequences provide simultaneous coverage over time under their assumptions. CAST's aggregate totals illustrate a working death-label bet, not its clinical monitoring history. E-BH combines valid null e-values for a specified family. CUSUM uses mean run length rather than an ever-alarm probability. Adaptive allocation needs appropriate inference, and logged propensities enable off-policy evaluation.

Many examples here used a fixed, small number of model parameters. That is a useful bridge to the next part, but not an assumption required by all the nonparametric and betting guarantees just developed. Part fifty-nine studies classical likelihood, estimation and bootstrap procedures when the number of fitted parameters grows proportionally with sample size.

Where it comes back. Part sixty's robustness when the future shifts. Part sixty-two's adaptive and sequential causal designs. Part sixty-three's privacy budgets, spent over time. Part sixty-four's evaluation of AI systems as they are deployed. And the dissertation's monitoring plan.

Six problems, with full solutions in the README. Wald's error bound; Wald's identity; Ville's inequality; calibrators and merging; Robbins's mixture sequence; and e-BH's guarantee. Pause here if you want to try them.

The books behind this part: Wald's and Siegmund's on sequential analysis; Jennison and Turnbull on group sequential methods; Shafer and Vovk's game-theoretic foundations; Ramdas and Wang on e-values; and Lattimore and Szepesvári on bandits; with the papers from Ville to the present.

Fifty-eight parts of sixty-five. Fit a logistic regression with one variable for every five observations, and the textbook likelihood-ratio test, the one every software package prints, is badly miscalibrated: its p-values are far too small. Pragya Sur and Emmanuel Candès worked out why, and what the right answer is. Next, Part fifty-nine: high-dimensional asymptotics.

Where it goes next. The proportional regime follows in Part 59 and shift in Part 60; adaptive and sequential causal designs and dynamic treatment regimes are in Part 62, privacy budgets spent over time in Part 63, the evaluation of deployed AI systems in Part 64, and the dissertation's monitoring plan in Part 65.

Key results

The part's results in one place, for revision.

Wald's SPRT\(\displaystyle \text{stop }\allowbreak \text{when } \Lambda_n\ge A=\frac{1-\beta}{\alpha}\ \text{or}\ \Lambda_n\le B=\frac{\beta}{1-\alpha}:\qquad\allowbreak \alpha'\le\frac{\alpha}{1-\beta},\quad\allowbreak \beta'\le\frac{\beta}{1-\alpha},\quad\allowbreak \alpha'+\beta'\le\alpha+\beta\)
Wald's identity\(\displaystyle \operatorname{E}S_N=\operatorname{E}N\cdot\operatorname{E}X_1\qquad\allowbreak (N \text{ a }\allowbreak \text{stopping }\allowbreak \text{time},\ \operatorname{E}N<\infty)\)
Ville's inequality\(\displaystyle M_t\ge 0 \text{ a }\allowbreak \text{supermartingale},\ M_0=1:\qquad\allowbreak P\bigl(\exists\,t:\ M_t\ge 1/\alpha\bigr)\le\alpha\)
e-values and calibrators\(\displaystyle \operatorname{E}_{H_0}E\le 1\ \Rightarrow\ P_{H_0}(E\ge 1/\alpha)\le\alpha;\qquad\allowbreak e=\kappa\,p^{\kappa-1}\ (0<\kappa<1)\ \text{is }\allowbreak \text{an }\allowbreak \text{e-value}\)
Robbins's mixture confidence sequence\(\displaystyle P\Bigl(\forall t:\ |\bar X_t-\mu|\le\sigma\,\frac{\sqrt{(1+t\tau^2)\bigl(\log(1+t\tau^2)+2\log(1/\alpha)\bigr)}}{t\,\tau}\Bigr)\ge 1-\alpha\)
e-BH\(\displaystyle k^*=\max\Bigl\{k:\ e_{(k)}\ge\frac{m}{\alpha k}\Bigr\},\ \text{reject }\allowbreak \text{the } k^* \text{ largest}:\qquad\allowbreak \mathrm{FDR}\le\frac{m_0}{m}\,\alpha\ \text{ under }\allowbreak \text{any }\allowbreak \text{dependence}\)

Try it

Lab 58 · Peeking, Ville's inequality and the SPRT

Check a 5% z-test after every observation of null data and count how often it ever rejects; do the same with a likelihood-ratio test martingale and Ville's threshold of 20, and with Robbins's mixture confidence sequence. Then compute Wald's SPRT for a defective rate of 10% against 20% exactly and compare its sample size with the fixed test's.

Figure produced by Lab 58: Peeking, Ville's inequality and the SPRT
Produced by the lab below, seed 0, in 0.4 s.
python -m videos.stats.labs 58 needs numpy, scipy, matplotlib · download lab58.py · source on GitHub
z-test rejects a true null within 1 look          4.8%   nominal 5%
z-test rejects a true null within 10 looks        18.7%   nominal 5%
z-test rejects a true null within 100 looks       36.3%   nominal 5%
z-test rejects a true null within 1000 looks      52.4%   nominal 5%
test martingale ever reaches 20 in 1,000 looks    4.0%   Ville's bound 5%
fixed-n interval covers at every t in [10, 1000]  56.0%   (at t = 1000 alone: 95.9%)
mixture confidence sequence covers at every t     97.6%   guarantee at least 95%
SPRT expected sample size at p = 0.1              56.9   Wald's approximation 54.4   fixed test n = 109
SPRT expected sample size at p = 0.2              59.3
SPRT error rates                                  3.9% and 9.7%   targets 5% and 10%

A fixed-n test looked at every step rejects a true null about half the time within a thousand looks; a nonnegative martingale crosses 1/alpha with probability at most alpha however often you look, and the SPRT built on that idea needs about half the fixed test's sample.
The code (99 lines; it asserts its own result)
"""Lab 58: look after every observation, with a z-test, a test martingale, the SPRT and a confidence sequence."""

import numpy as np
from scipy import stats

from videos.coursekit import labs
from explainer.stats.kit import sequential

TITLE = "Peeking, Ville's inequality and the SPRT"
GOAL = ("Check a 5% z-test after every observation of null data and count how often it ever rejects; do the same "
        "with a likelihood-ratio test martingale and Ville's threshold of 20, and with Robbins's mixture confidence "
        "sequence. Then compute Wald's SPRT for a defective rate of 10% against 20% exactly and compare its "
        "sample size with the fixed test's.")
TASKS = [
    "Change the martingale's bet mu1 from 0.2 to 0.05 and to 1. Ville's bound holds each time; which bet crosses 20 soonest when the true mean is 0.2?",
    "Replace the normal data by centred exponentials (rng.exponential(size) - 1). Does the mixture confidence sequence, built for sub-Gaussian data, still cover at every time?",
    "Evaluate sequential.sprt_bernoulli_exact at p = 0.15, between the hypotheses. How does the expected sample size compare with the fixed test's 109, and what does Wald's approximation say?",
]


def run(seed=0):
    rng = np.random.default_rng(seed)
    alpha, T, reps = 0.05, 1000, 4000
    lab = labs.Lab()

    # 1. peeking against Ville, on N(0, 1) data
    looks = np.array([1, 10, 100, 1000])
    peek = sequential.peeking_curve(looks, alpha, reps, rng)
    v = sequential.ville_check(T, 0.2, alpha, reps, rng)
    for n, p in zip(looks, peek):
        lab.row(f"z-test rejects a true null within {n} look{'s' if n > 1 else ''}", f"{p:.1%}   nominal {alpha:.0%}")
    lab.row("test martingale ever reaches 20 in 1,000 looks", f"{v['ville']:.1%}   Ville's bound {alpha:.0%}")

    # 2. a confidence sequence against the fixed-n interval, at every time from 10 to 1,000
    z = stats.norm.isf(alpha / 2)
    t = np.arange(1, T + 1)

    def clt(x):
        m = np.cumsum(x) / t
        return m - z / np.sqrt(t), m + z / np.sqrt(t)

    def mixture(x):
        return sequential.normal_mixture_cs(np.cumsum(x) / t, t, alpha)

    def sampler(r, n):
        return r.standard_normal(n)

    c_clt = sequential.cs_coverage(clt, sampler, T, 1500, 0.0, rng, t_min=10)
    c_mix = sequential.cs_coverage(mixture, sampler, T, 1500, 0.0, rng, t_min=10)
    lab.row("fixed-n interval covers at every t in [10, 1000]", f"{c_clt['uniform']:.1%}   (at t = 1000 alone: {c_clt['final']:.1%})")
    lab.row("mixture confidence sequence covers at every t", f"{c_mix['uniform']:.1%}   guarantee at least {1 - alpha:.0%}")

    # 3. Wald's SPRT, exactly: defective rate 10% against 20%, alpha 5%, beta 10%
    p0, p1, beta = 0.1, 0.2, 0.1
    fixed = sequential.fixed_n_binomial(p0, p1, alpha, beta)
    e0 = sequential.sprt_bernoulli_exact(p0, p0, p1, alpha, beta)
    e1 = sequential.sprt_bernoulli_exact(p1, p0, p1, alpha, beta)
    w0 = sequential.sprt_wald_approx(p0, p0, p1, alpha, beta)
    lab.row("SPRT expected sample size at p = 0.1", f"{e0['asn']:.1f}   Wald's approximation {w0['asn']:.1f}   fixed test n = {fixed['n']}")
    lab.row("SPRT expected sample size at p = 0.2", f"{e1['asn']:.1f}")
    lab.row("SPRT error rates", f"{e0['accept_h1']:.1%} and {e1['accept_h0']:.1%}   targets {alpha:.0%} and {beta:.0%}")
    lab.note = ("A fixed-n test looked at every step rejects a true null about half the time within a thousand looks; "
                "a nonnegative martingale crosses 1/alpha with probability at most alpha however often you look, "
                "and the SPRT built on that idea needs about half the fixed test's sample.")
    assert peek[0] < 0.07 and peek[2] > 0.3 and peek[3] > 0.45 and np.all(np.diff(peek) > 0), "peeking inflates the error"
    assert 0.01 < v["ville"] <= alpha + 0.01, "Ville's inequality holds and is not vacuous"
    assert c_mix["uniform"] >= 0.95 and c_clt["uniform"] < 0.75 and abs(c_clt["final"] - 0.95) < 0.025, "only the confidence sequence is time-uniform"
    assert e0["accept_h1"] <= alpha and e1["accept_h0"] <= beta, "Wald's thresholds keep both error rates"
    assert max(e0["asn"], e1["asn"]) < 0.6 * fixed["n"] and abs(w0["asn"] / e0["asn"] - 1) < 0.15, "the SPRT's saving"

    fig, ax = labs.figure(2, size=(11, 4.2))
    grid = np.unique(np.round(np.logspace(0, 3, 40)).astype(int))
    curve = sequential.peeking_curve(grid, alpha, 2000, rng)
    ax[0].plot(grid, curve, color=labs.RED, label="z-test, checked after every observation")
    ax[0].axhline(v["ville"], color=labs.GREEN, label=f"martingale ever at 20 (1,000 looks): {v['ville']:.1%}")
    ax[0].axhline(alpha, color=labs.MUTED, ls="--", lw=1, label="nominal 5%")
    ax[0].set(title="Chance of ever rejecting a true null", xlabel="number of looks (log scale)", ylabel="probability",
              xscale="log", ylim=(0, 0.62))
    ax[0].legend(loc="upper left")
    x = rng.standard_normal(T)
    for _ in range(200):  # a stream whose fixed-n interval excludes the truth at some time after 10
        lo, hi = clt(x)
        if ((lo > 0) | (hi < 0))[9:].any():
            break
        x = rng.standard_normal(T)
    lo, hi = clt(x)
    mlo, mhi = mixture(x)
    out = np.flatnonzero((lo > 0) | (hi < 0))
    out = out[out >= 9]
    ax[1].fill_between(t, mlo, mhi, color=labs.GOLD, alpha=0.18, label="mixture confidence sequence")
    ax[1].fill_between(t, lo, hi, color=labs.BLUE, alpha=0.35, label="fixed-n 95% interval")
    ax[1].plot(t, np.cumsum(x) / t, color=labs.INK, lw=1.2, label="running mean")
    ax[1].plot(t[out], np.zeros(len(out)), ".", color=labs.RED, ms=4, label="fixed-n interval excludes the truth")
    ax[1].axhline(0, color=labs.MUTED, lw=1)
    ax[1].set(title="One null stream: two bands around the running mean", xlabel="observations (log scale)", ylabel="mean",
              xscale="log", xlim=(10, T), ylim=(-1.3, 1.8))
    ax[1].legend(loc="upper right")
    lab.fig = fig
    return lab

Now change it

  1. Change the martingale's bet mu1 from 0.2 to 0.05 and to 1. Ville's bound holds each time; which bet crosses 20 soonest when the true mean is 0.2?
  2. Replace the normal data by centred exponentials (rng.exponential(size) - 1). Does the mixture confidence sequence, built for sub-Gaussian data, still cover at every time?
  3. Evaluate sequential.sprt_bernoulli_exact at p = 0.15, between the hypotheses. How does the expected sample size compare with the fixed test's 109, and what does Wald's approximation say?

Problems, with solutions

Try each problem before opening its solution.

  1. Wald's bound. Show that Wald's thresholds give \(P_0(\text{reject}) \le \alpha/(1 - \beta)\), by a change of measure.

    Solution

    On {reject}, Λ_N ≥ A. Then P₁(reject) = E₀[Λ_N; reject] ≥ A P₀(reject), so P₀(reject) ≤ P₁(reject)/A ≤ 1/A = α/(1 − β).

  2. Wald's identity. Prove Wald's identity \(E[S_N] = E[N]\,E[Z_1]\) for a stopping time with \(E N < \infty\).

    Solution

    For IID integrable increments and finite EN, S_N = Σ_i Z_i 1{N ≥ i}, and {N ≥ i} is determined by Z_1, …, Z_{i−1}, so it is independent of Z_i. Hence E S_N = Σ_i E Z_i P(N ≥ i) = E Z₁ Σ_i P(N ≥ i) = E Z₁ E N, the exchange justified by Σ E|Z_i| 1{N ≥ i} = E|Z₁| E N < ∞.

  3. Ville. Prove Ville's inequality \(P(\sup_t M_t \ge 1/\alpha) \le \alpha\) for a nonnegative martingale with \(M_0 = 1\).

    Solution

    Let τ = inf{t: M_t ≥ 1/α} ∧ T. By optional stopping at the bounded time τ, 1 = E M_τ ≥ (1/α) P(max_{t≤T} M_t ≥ 1/α). Let T → ∞ (monotone convergence).

  4. Calibrators and merging. Show that \(f_\kappa(p) = \kappa p^{\kappa - 1}\) is a calibrator, and that the mean of e-values is an e-value.

    Solution

    For 0<κ<1, f_κ is decreasing, and ∫₀¹ κp^{κ−1} dp = 1, so E f_κ(P) ≤ 1 whenever P is super-uniform (integrate f_κ against the distribution of P, using that f_κ is decreasing). For e-values E_1, …, E_K, E[(1/K) Σ E_k] = (1/K) Σ E E_k ≤ 1, with no assumption on dependence.

  5. Robbins's mixture. Derive Robbins's normal-mixture confidence sequence from the mixture martingale.

    Solution

    ∫ exp(λS − λ²t/2) φ_τ(λ) dλ = (1 + tτ²)^{−1/2} exp(τ²S²/(2(1 + tτ²))). Setting it < 1/α and solving gives S² < ((1 + tτ²)/τ²)(log(1 + tτ²) + 2 log(1/α)); divide by t² for the mean. Ville makes it hold at all t at once.

  6. e-BH. Show that e-BH controls the FDR at \(\alpha m_0/m\) under arbitrary dependence.

    Solution

    If H_i is rejected, e_i ≥ m/(αR), so 1{i rejected}/(R ∨ 1) ≤ α e_i/m. Summing over nulls and taking expectations, FDR ≤ (α/m) Σ_{i null} E e_i ≤ α m₀/m.

Notes and sources

Where it comes back

  • Part 59: classical statistics when p and n grow together.
  • Part 60: robustness when the future shifts.
  • Part 62: adaptive and sequential causal designs, and dynamic treatment regimes.
  • Part 63: privacy budgets spent over time.
  • Part 64: evaluating AI systems as they are deployed.
  • Part 65: the dissertation's monitoring plan.

Glossary

  • Sequential tests. SPRT; likelihood-ratio walk; Wald's thresholds; operating characteristic; average sample number; Wald's identity; overshoot; truncation; Wald–Wolfowitz optimality.
  • Group sequential. Information fraction; Brownian picture; Pocock and O'Brien–Fleming boundaries; spending function; stagewise ordering; median-unbiased estimate.
  • Anytime-valid. Test martingale; Ville's inequality; optional stopping; e-value; e-process; calibrator; Kelly criterion; growth rate; universal inference; split LRT; GROW; reverse information projection; confidence sequence; stitching; betting confidence sequence; anytime-valid p-value; power-one test; Forecaster, Skeptic and Reality; upper probability; e-BH.
  • Change. CUSUM; average run length; Lorden's criterion; run length; hazard; BOCPD; e-detector.
  • Adaptive experiments. Thompson sampling; regret; Lai–Robbins bound; exploration sampling; propensity floor; AIPW score; adaptive weighting; batched bandits; off-policy evaluation; IPW; doubly robust estimator.

Sources

  • History. W. A. Wallis, JASA 75 (1980); A. Wald, Ann. Math. Stat. 16 (1945) and Sequential Analysis (1947); A. Wald & J. Wolfowitz, Ann. Math. Stat. 19 (1948); D. Siegmund, Sequential Analysis (1985).
  • Group sequential. P. Armitage, C. McPherson & B. Rowe, JRSS A 132 (1969); S. Pocock, Biometrika 64 (1977); P. O'Brien & T. Fleming, Biometrics 35 (1979); K. K. G. Lan & D. DeMets, Biometrika 70 (1983); C. Jennison & B. Turnbull, Group Sequential Methods with Applications to Clinical Trials (2000).
  • Martingales and e-values. J. Ville, Étude critique de la notion de collectif (1939); G. Shafer, JRSS A 184 (2021); V. Vovk & R. Wang, Ann. Stat. 49 (2021); J. Kelly, Bell System Technical Journal 35 (1956); G. Shafer & V. Vovk, Probability and Finance (2001) and Game-Theoretic Foundations for Probability and Finance (2019); A. Ramdas & R. Wang, Hypothesis Testing with E-values (2024).
  • Composite nulls. L. Wasserman, A. Ramdas & S. Balakrishnan, PNAS 117 (2020); P. Grünwald, R. de Heide & W. Koolen, JRSS B 86 (2024); M. F. Pérez-Ortiz, T. Lardy, R. de Heide & P. Grünwald, Ann. Stat. (2024).
  • Confidence sequences. D. Darling & H. Robbins, PNAS 58 (1967); H. Robbins, Ann. Math. Stat. 41 (1970); S. Howard, A. Ramdas, J. McAuliffe & J. Sekhon, Ann. Stat. 49 (2021); I. Waudby-Smith & A. Ramdas, JRSS B 86 (2024); R. Johari, P. Koomen, L. Pekelis & D. Walsh, Operations Research 70 (2022).
  • Multiple testing. R. Wang & A. Ramdas, JRSS B 84 (2022); Z. Xu, A. Solari, L. Fischer, R. de Heide, A. Ramdas & J. Goeman, arXiv:2509.02517v3 (2026); Z. Ren & R. Foygel Barber, JRSS B 86 (2024).
  • Change detection. E. Page, Biometrika 41 (1954); G. Lorden, Ann. Math. Stat. 42 (1971); G. Moustakides, Ann. Stat. 14 (1986); R. Adams & D. MacKay, arXiv:0710.3742 (2007).
  • Bandits and adaptivity. W. Thompson, Biometrika 25 (1933); T. L. Lai & H. Robbins, Adv. Appl. Math. 6 (1985); E. Kaufmann, N. Korda & R. Munos, ALT (2012); M. Kasy & A. Sautmann, Econometrica 89 (2021); X. Nie, X. Tian, J. Taylor & J. Zou, AISTATS (2018); K. Zhang, L. Janson & S. Murphy, NeurIPS (2020); V. Hadad, D. Hirshberg, R. Zhan, S. Wager & S. Athey, PNAS 118 (2021); M. Dudík, J. Langford & L. Li, ICML (2011); T. Lattimore & C. Szepesvári, Bandit Algorithms (2020).
  • Data. D. Echt et al., NEJM 324 (1991); G. Cobb, Biometrika 65 (1978); J. Durbin & S. J. Koopman, Time Series Analysis by State Space Methods (2012).
About this partfrom its README

Part 58 of a sixty-five-part course in statistics, from a first course to a PhD (see the series plan and the syllabus), and the third part of Stage V, the research frontier.

It opens with the Statistical Research Group at Columbia in 1943 (Wallis 1980). A Navy officer complained that a test of two alternative methods ran its full length long after the answer was clear, and Abraham Wald answered with the sequential probability ratio test. On Wald's kind of example (a defective rate of 10% against 20%, α = 5%, β = 10%), the exact SPRT needs 56.9 shells on average when the rate is 10% and 59.3 when it is 20%. The smallest nonrandomized one-sided count test meeting those targets needs 109. The unplanned way to look early, checking a 5% z-test after every observation, rejects a true null 38% of the time within 100 looks and 62% within 5,000. The part asks how to test and estimate when you look whenever you like, and when you choose what to collect as you go:

  • the SPRT, computed exactly on the lattice: thresholds, paths, Wald's error bounds and identity, the OC and ASN curves against Wald's approximations, the long tail of N, Wald–Wolfowitz optimality, overshoot;
  • group-sequential theory in the Brownian picture: Pocock and O'Brien–Fleming, Lan–DeMets spending, the bias of the mean at stopping, stagewise ordering;
  • test martingales and Ville's inequality, proved by optional stopping; peeking against Ville; null and alternative wealth paths; tests of power one; anytime-valid p-values;
  • testing by betting (Shafer 2021): e-values, calibrators (Vovk & Wang 2021), merging, Kelly growth;
  • composite nulls: universal inference (Wasserman, Ramdas & Balakrishnan 2020) against the t-test; GROW e-values and the reverse information projection (Grünwald, de Heide & Koolen 2024); invariance (Pérez-Ortiz et al. 2024);
  • confidence sequences: Robbins's normal mixture, the LIL limit and stitching (Howard et al. 2021), betting confidence sequences (Waudby-Smith & Ramdas 2024), on the World's A/B platform;
  • CAST (Echt et al. 1991) as a working death-label betting illustration, with simulated orders;
  • game-theoretic probability (Shafer & Vovk): the protocol, upper probability, the law of large numbers by betting, testing a forecaster;
  • e-BH (Wang & Ramdas 2022), its proof, against BH, and closed e-BH (Xu et al., arXiv:2509.02517v3, 2026);
  • change detection: CUSUM (Page 1954), Lorden's criterion, ARLs, the Nile, Bayesian online changepoint detection (Adams & MacKay 2007);
  • bandits: Thompson sampling (1933), Lai–Robbins, exploration sampling for policy choice (Kasy & Sautmann 2021);
  • inference after adaptivity: negative bias (Nie et al. 2018), batched bandits (Zhang, Janson & Murphy 2020), adaptively weighted AIPW (Hadad et al. 2021);
  • off-policy evaluation by IPW and doubly robust estimators;
  • five open problems.

It keeps two promises:

  • Part 10 computed a p-value once, at a planned n. Chapters 3–7 give e-values and test martingales, valid at every look.
  • Part 35 gave group-sequential boundaries for planned looks. Chapter 2 gives them the Brownian picture, and chapter 6 lets you look at any time.

Built in this part:

  • statkit.sequential (explainer/stats/kit/sequential.py), tested in tests/test_stats_kit_sequential.py:
    • the Bernoulli SPRT, exact on the lattice (OC, ASN, the stopping-time law) and by Wald's approximations, the fixed-n binomial comparison, single paths;
    • the bias of the mean after a group-sequential stop;
    • likelihood-ratio test martingales, Ville's check, the peeking curve;
    • calibrators, e-to-p, merging, e-BH, and the split-LRT e-value for a normal mean with unknown variance;
    • normal-mixture, stitched (LIL) and Hoeffding (fixed and union-bound) sequences, and the hedged betting confidence sequence for bounded data, with a time-uniform coverage harness;
    • CUSUM with average run lengths, and Bayesian online changepoint detection for a normal mean;
    • Thompson sampling with recorded propensities, AIPW scores, adaptively weighted estimates and intervals, and IPW and doubly robust policy values.
  • The confidence funnel (ConfidenceFunnel in explainer/stats/viz.py), the part's instrument: a stream's running estimate on a log-time axis, with bands for any method (a fixed-n interval, a confidence sequence), the truth, and dots at the times a band excluded it.

Data.

  • From the Museum: CAST's deaths (Echt et al. 1991) and the Nile's annual flow (Cobb 1978).
  • From the World: the A/B platform's conversion streams (seeded).
  • The rest is exact arithmetic or seeded simulation.

The Coverage Board gains four rows:

Method Setting Nominal Achieved Verdict
fixed-n CLT interval, checked every visit conversion 12%, visitors 20 to 2,000 95% 46.3% broken
betting confidence sequence conversion 12%, visitors 20 to 2,000 95% 97.0% kept
naive interval after Thompson sampling two equal arms, 1,000 visitors 95% 90.0% broken
adaptively weighted AIPW interval two equal arms, 1,000 visitors 95% 93.7% kept
Chapter notes
# Chapter Numbers
0 The Statistical Research Group p₀ = 0.1, p₁ = 0.2, α = 5%, β = 10%: fixed test n = 109 (reject at ≥ 17); SPRT E N = 56.9 and 59.3, errors 3.9% and 9.7%; peeking: 38% by 100 looks, 62% by 5,000
1 The SPRT steps +0.693 per defective, −0.118 per good; band (−2.25, 2.89); 12 lots each: mean 43 and 60 shells; ASN peaks at 88.6 near p = 0.15 (Wald 79.4); P(N > 109) = 9.3% and 11.7%
2 Group-sequential K = 5: Pocock 2.413; O'Brien–Fleming 4.56, 3.23, 2.63, 2.28, 2.04; maximum observed overall bias on five effects ≈ 0.023 SD, but about 0.14 given a positive early stop at θ = 0.1 (16% stop early)
3 Ville 20,000 null streams: Ville's test (M ≥ 20, 1,000 looks) 4.1%; peeking 53% by 1,000 looks
4 Betting p = 0.05 → e = 2.24 (κ = ½), p = 0.001 → 15.8; five studies: P(E ≥ 20) 26% (one), 46% (average), 82% (product)
5 Composite nulls n = 40, σ unknown: t-test 4.7% under H₀, universal inference 0.1%; at μ = 0.5, 87% vs 18%
6 Confidence sequences 300 streams, t ∈ [20, 2,000]: CLT 46.3% uniform (94% at the end), mixture 100%, betting 97.0%; widths at 5,000: CLT ±0.91, betting ±1.85, mixture ±2.38, stitched ±2.96, union Hoeffding ±4.61 points
7 CAST 63 of 89 deaths on the drugs: mixture wealth 333 (anytime p ≤ 0.003; fixed z = 3.92, p ≈ 9 × 10⁻⁵); over random orders wealth reaches 20 after a median of 45 deaths (10%–90%: 16–71)
8 Game-theoretic probability a forecaster saying 30% when it rains 40%: growth 0.0225 a day at λ = ½, log-drift crossing approximation about 204 days under IID .4 rain; random waiting time
9 e-BH 50 metrics, 10 effects of 3 SD, equicorrelation 0.6, q = 0.1: BH FDR 6.7%, power 77%; e-BH 1.0%, 47%
10 Change detection ARL₀ / delay for a 1-SD shift: h = 2: 36 / 4.5; 3: 117 / 6.6; 4: 345 / 8.2; 5: 871 / 10.3; the Nile: mean 1,098 → 850, CUSUM alarm 1901, posterior-favoured change 1899 under the chosen BOCPD model
11 Bandits 10% vs 12%, 4,000 visitors, 60 runs: balanced loses 40 conversions, Thompson 16 (88% to the better design by the end); Lai–Robbins constant 10, so 10 log T ≈ 83 at T = 4,000
12 Adaptivity finite-MC matching with true 1% floor, two equal arms, 1000 runs: arm A allocation 10%–90% 115–863; naive bias -1.71 points, coverage 90.0%; weighted bias -0.98, coverage 93.7%
13 Off-policy fixed always-A target .10, 200 runs: IPW 0.0991 (SD 0.0156, coverage 92.5%); DR 0.0990 (SD 0.0149, coverage 92.0%); asymptotic normal intervals
14 Open problems —
15 Outro —

Companion material in this repository

The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
  1. Hook: the Statistical Research Group (1943). Wald's SPRT; Wallis (1980). Upgrade cards from Parts 10 and 35.
  2. The SPRT. Wald's approximations and identity; optimality (Wald & Wolfowitz 1948).
  3. Group sequential theory. Spending functions in the Brownian picture; estimation after stopping.
  4. Test martingales and Ville (Part 44) (BettingPaths).
  5. Testing by betting (Shafer 2021; Shafer & Vovk). e-values; calibrators (Vovk & Wang 2021); merging.
  6. Composite nulls. Universal inference (Wasserman, Ramdas & Balakrishnan 2020); GROW e-values and reverse information projections (Grünwald, de Heide & Koolen 2024).
  7. Confidence sequences. Mixtures (Robbins 1970); LIL-rate boundaries (Howard et al. 2021); betting CSs (Waudby-Smith & Ramdas 2024) (Board).
  8. Game-theoretic probability. Shafer & Vovk's framework; e-values as evidence.
  9. Multiple testing with e-values. e-BH (Wang & Ramdas 2022); e-closure (verify).
  10. Change detection. CUSUM (Page 1954); Lorden's optimality; BOCPD.
  11. Bandits and adaptive designs. Thompson (1933); Lai–Robbins; adaptive experiments for inference (Kasy & Sautmann 2021 (verify)).
  12. Inference after adaptivity. Bias of sample means (Nie et al. 2018); adaptive weighting (Hadad et al. 2021); batched bandits (Zhang, Janson & Murphy 2020) (Board).
  13. Off-policy evaluation. IPW and doubly robust policy values; their variance.
  14. Open problems.

Built: statkit.sequential; the World's A/B platform. Books: Wald; Siegmund; Jennison & Turnbull; Ramdas & Wang; Shafer & Vovk; Lattimore & Szepesvári.

Build the film

python -m videos.stats.stats58.compute        # the part's numbers, into .cache/stats58
python tools/build.py stats58                  # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py stats58 Hook   # one chapter, silent, with a contact sheet

Scenes: videos/stats/stats58. Setup: see the course page. Source of these notes: the README and the scenes' narration.

Build it
OMP_NUM_THREADS=1 python -m videos.stats.stats58.compute   # once (about three minutes)
python tools/build.py stats58 -q l                         # fast 480p preview
python tools/build.py stats58                              # 1080p30 -> renders/stats58.mp4
python tools/qa_scene.py stats58 ConfidenceSequences
python tools/lecture_length.py stats58 --floor 50