Manuscript Offprint
arXiv:2610.20375Hypothesis Selection via Weighted Medians
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Given distributions (hypotheses) and samples from an unknown target distribution , proper hypothesis selection seeks a distribution whose total variation distance to is close to the best achievable within the known distributions. We give an algorithm that, using target samples, running in time, with probability at least , returns satisfying . The algorithm achieves the optimal approximation factor and sample complexity. The running time improves the dependence on the failure probability from polynomial to logarithmic in the state-of-the-art bound of Aamand, Aliakbarpour, Chen, and Silwal (COLT 2026), thereby answering their Question 2.
1 Introduction
Selecting a probability distribution from a finite class is a basic task in statistical learning. The target distribution need not belong to the class: the aim is to compete with the best available distribution using samples from the target. In hypothesis selection, the quality of this approximation is measured in total variation distance, and the challenge is to obtain statistical guarantees with a running time that scales favorably with the number of distributions.
Let be a class of distributions, each a probability measure on a measurable space , and let be the unknown target distribution. Fix a common dominating measure for , and write for the density of . We have sample access to and sample and density-query access to every ; the density of is not available to the algorithm. Writing , the goal is to return a probability measure such that, with probability at least ,
Here is the additive error and is the failure probability. The selection is proper if ; otherwise, the algorithm is allowed to be improper.
Statistical guarantees. Classical minimum-distance methods achieve approximation factor using samples from [Yat85, DL01]. The factor 3 is also optimal for proper selection with a sample size independent of the domain size [BKM19, AACS26]. Allowing an improper output improves the achievable factor to 2 [BKM19, BBK22]. Thus, for proper selection, the remaining issue is how efficiently the optimal statistical guarantee can be attained.
Computational guarantees. Classical factor-3 selectors have cubic or quadratic running times in [DL01, MS08]. Aliakbarpour, Bun, and Smith [ABS24] obtained a nearly linear dependence on , with running time and optimal target-sample complexity. Aamand, Aliakbarpour, Chen, and Silwal [AACS26] improved the running time to for . Selected bounds are compared in
| Algorithm | Running time | Failure probability | Comments |
|---|---|---|---|
| Minimum distance [Yat85, DL01] | |||
| Modified minimum distance [MS08] | |||
| Approx min distance [ABS24] | |||
| Semi-distance threshold [AACS26, Theorem 1.3] | |||
| This paper, Theorem 1.1 |
Table 1: Proper hypothesis selection with approximation factor 3. All rows use target samples; for polynomially small failure probability, this is . More results are collected in [AACS26, Table 1].
Table 1. Aamand et al. ask whether proper selection can simultaneously achieve factor 3, target samples, and running time [AACS26, Question 2]. We answer this question affirmatively.
Theorem 1.1. Let , , and . Algorithm 1 returns a distribution such that, with probability at least ,
The algorithm uses target samples, and runs in time.
For each , define a test that equals when is below the median and when it is above. A fractional value on ties ensures the pointwise identities
The first identity balances the tests under the current weights; the second connects them to distances from the median measure.
In each round, the algorithm draws one sample from and one sample from a proposal mixture of the input distributions. The proposal mixture is constructed to be close to the mixture of the input distributions under the current weights, and can be sampled efficiently. These two samples produce a bounded gain estimate for each distribution, with conditional expectation given the previous rounds. A positive gain indicates that the corresponding distribution is closer to the median than is. A multiplicative update then increases the weights of distributions with positive gain.
The balance identity gives for every realization, so the update preserves the sum of the weights without renormalization. A standard multiplicative-weights argument [AHK12] bounds the average realized gain of every distribution by . Concentration for bounded martingale differences transfers this bound to the average conditional gains along the adaptive run. The second identity above yields, for every ,
where records the randomness through round . Consequently, for a best input distribution , the average distance is at most with high probability. Using as the intermediate measure in the triangle inequality gives
To obtain a proper output, the algorithm also uses the proposal samples to form bounded, unbiased estimates of for every . These estimates include a mass correction because is not normalized. The algorithm returns minimizing the estimated average distance to the median measures. Uniform concentration of the distance estimates ensures that its true average distance is at most . Averaging the triangle inequality through therefore yields
The analysis in Section 4 tracks the constants to obtain with probability at least after rounds. Each round uses one target sample and time, giving the claimed sample complexity and running time.
2 Preliminaries
2.1 Problem setting and computational model
Let be probability distributions on a measurable space , and let be the unknown target distribution on the same space. Fix a common -finite dominating measure for , and write
Here is the density of the distribution relative to . The target density is used only as mathematical notation and is not available to the algorithm. We access through a sample oracle, and each through a sample oracle and a density oracle that evaluates at any supplied point . Every sample-oracle call returns a fresh independent draw from the requested measure.
For accuracy and failure probability , our goal is to return a distribution such that
with probability at least over the samples and the algorithm’s internal randomness. The selection is proper because the output must be one of the input distributions.
We use an exact-real oracle model: sample-oracle calls, density evaluations, arithmetic operations (addition, subtraction, multiplication, or division), comparisons, ceiling operations, and draws from uniform distributions each take unit time. The algorithm’s running time is the total number of such operations. The sample complexity only counts the number of samples drawn from the target distribution P.
2.2 Notation and density conventions
Write , use for the natural logarithm and for the base-two logarithm, and set . Throughout the paper, fix , breaking ties by a fixed rule.
Uppercase symbols denote measures and their lowercase counterparts denote densities relative to . In particular, , , and denote the densities of the mixtures , , and the median measure introduced in Section 3.
Since is the density of with respect to , denotes the probability of a measurable set . The same convention applies to , , and , although need not have mass one.
2.3 Total variation and finite measures
For a finite signed measure on , write for its total variation norm. If has density relative to , then . For probability measures , we use
For finite nonnegative measures and any measurable function with , the signed-measure norm gives
We also use the triangle inequality for this norm, which applies even when the intermediate measure is not a probability measure. In particular, for probability measures A, B and a finite nonnegative measure U,
When , the quantity denotes half the signed-measure norm, rather than the total variation distance between two probability measures.
A useful identity accounts explicitly for the mass of such a measure. If has density and mass , then
(2)
Indeed, and give this identity directly. The correction is needed because the median measures used by the algorithm are not normalized.
3 The algorithm
3.1 Weighted medians and balanced tests
Let be a vector of positive weights with , and let be the corresponding mixture of the distributions. Then is a probability measure with density .
Let be the lower weighted median of : the smallest input value whose cumulative weight is at least 1/2. The function is measurable, since it is selected from finitely many measurable density functions using measurable comparisons. Define the median measure by . Its mass need not be one, so we do not normalize it.
Let be the total weight on density values below , with and defined analogously. Define the balanced median tests by
The tests are measurable signed functions that indicate whether is below or above the median, with a fractional tie value that exactly balances the total weight on each side. The denominator is positive because the median is an input value and all weights are positive.
Lemma 3.1 (Weighted-median identities). For every and ,
In particular, U is a finite nonnegative measure with .
Proof of Lemma 3.1. Fix . The lower-median definition gives and . Since , these inequalities imply
Thus the tie value lies in , proving the first identity.
Summing the three cases of Eq. (3) gives
The third identity follows directly from the sign of .
Finally, at least half the weight lies on values at least , so
Integrating gives .
The fractional tie value is essential to exact balance: replacing it by a fixed sign or by zero does not preserve in general. At any point where all candidate densities vanish, , , and , so for every . This includes target samples that fall in the measurable set .
3.2 Rounded weights and proposal sampling
We construct a proposal distribution by rounding the weights to dyadic probabilities. This construction ensures and allows exact sampling using a uniform integer draw followed by a sample from one of the input distributions.
Choose the least power of two , so , once for the entire run. Given w, first set . Increase by , so that the final integer weights sum to , and define the rounded weights, mixture, and density by
Lemma 3.2 (Proposal properties). For every and ,
Proof of Lemma 3.2. Before increasing , positivity of the weights gives , and hence . The remaining integer mass is nonnegative, and adding it to preserves and . Dividing by gives the first two inequalities. Multiplying by and summing gives ; the last inequality follows from Lemma 3.1.
Sampling from . Draw in unit time. Scan the cumulative sums to find the unique index such that , and return a fresh sample from . The index equals with probability , so the returned point has law . The sampling time is : the uniform draw and candidate-sample call each take unit time, and the cumulative scan takes time.
3.3 The iterative procedure
The algorithm is given in Algorithm 1. Define the number of rounds
Let be the filtration generated by the random choices in the algorithm, with containing the fixed input. Conditional on , the weights , median measure , tests , and proposal are fixed. Draw conditionally independent fresh samples and , and define
Since every , if then all and vanish. Ratios with denominator are defined to be zero. This convention preserves the integral identities, and assigns that set probability zero. The expectation calculations in Section 4.2 make this explicit.
Gains and distance estimates. Starting from uniform weights, we increase the weight of distributions with positive gain through the multiplicative update in Algorithm 1. The gain compares the median measure with the target through the balanced tests, while the distance estimates the distance from a distribution to the median measure. More precisely, Section 4.2 proves that
Algorithm 1: Proper hypothesis selection by unnormalized weighted medians
Input: Sample oracle for ; sample and density oracles for ; accuracy and failure probability .
Output: An input distribution .
1 Choose as the least power of two at least ; set as in Eq. (4)
2 Initialize and for every
3 for do
4 Use to define and by Eq. (3)
5 Construct and using the rounding procedure of Lemma 3.2
6 Draw independent fresh samples and
7 Evaluate all , the two weighted medians and their tests, and
8 Compute by Eq. (5)
9 for do
10 Compute and by Eq. (6) and Eq. (7)
11
12
13 Return for , breaking ties by a fixed rule
Each round takes linear time. The algorithm represents implicitly through the weights and the densities of the candidate distributions. In each round, it computes the weighted median and tests only at and . These computations take time by Section A. Rounding, proposal sampling, density evaluation, and the updates also take time, giving a total of per round.
4 Analysis of the algorithm
4.1 Bounded estimates and valid weights
Suppose that the current weights are positive and sum to one. By Lemma 3.2, , so and
Together with , these bounds imply
Validity of the update. The initial weights are positive and sum to one. The balance identity in Lemma 3.1 holds pointwise, and therefore
Consequently,
Moreover, , so every update factor is positive. Induction shows that all weight vectors, medians, and proposals are well defined, and that Eq. (8) holds in every round.
The following standard multiplicative-weights argument [AHK12] uses exact balance to obtain a bound for every distribution.
Lemma 4.1 (Deterministic gain bound). For every sample sequence and every ,
Proof. Since and , it holds that
where the first inequality uses for , and the second uses . The weights are positive and sum to one, so . Rearranging gives
Finally, since , we have . Together with , this gives
4.2 Conditional expectations
Recall the filtration from Section 3.3. Define
These quantities use the signed-measure norm because need not have mass one. By Lemma 3.1, , and hence
Lemma 4.2 (Conditional expectations). For every round and coordinate ,
Proof. Conditional on , the current weights, median, tests, and proposal are fixed, and and are fresh and independent. By the sign identity in Lemma 3.1,
(9)
Importance sampling gives
The first equality is the definition of expectation under . The last equality uses wherever , with the ratio defined to be zero on this null set of . Since , we obtain
Combining Eqs. (9) and (10) and applying Eq. (1) yields
For the distance estimate, Eq. (2) gives
Both and vanish wherever , so the same importance-sampling calculation yields
Substituting into Eq. (7) proves
☐
Why use the mass correction? The direct importance estimate introduces the ratio , for which the bound depends on . In contrast, , so the positive-part ratio in Eq. (7) is at most four. The mass correction in Eq. (11) makes this estimate unbiased even though is not normalized. The resulting estimate may be negative, but its conditional mean is nonnegative and its range has length four, independently of and the current weights.
4.3 Concentration for the adaptive sequence
The medians and proposals depend on previous samples, so we use a conditional form of the Azuma–Hoeffding inequality [Azu67, Hoe63].
Lemma 4.3 (Azuma–Hoeffding inequality). Let be a filtration and let be a sequence of random variables, each -measurable with . Suppose that almost surely, where , are -measurable and for a constant . Then for ,
The same bound holds for the lower tail.
Lemma 4.4 (Concentration of gains and distance estimates). With probability at least , the following inequalities hold simultaneously for every :
Proof. The choice of T in Eq. (4) and imply
For a fixed , the differences have conditional mean zero and conditional range of length five by Eq. (8); centering shifts an interval without changing its length. Apply Lemma 4.3 with and to bound the probability that the first inequality fails for this by . A union bound over gives failure probability at most .
By Lemma 4.2, has conditional mean zero, and its conditional range has length four by Eq. (8). Apply both tails of Lemma 4.3 with and to bound the probability that the second inequality fails for this by . A union bound over gives failure probability at most .
Combining the two failure probabilities proves the simultaneous guarantee. Neither independence across coordinates nor independence between the gain and score estimates is needed.
Combining Lemmas 4.1, 4.2 and 4.4 gives the following corollary.
Corollary 4.5. With probability at least , the following inequalities hold simultaneously for every :
4.4 Proof of Theorem 1.1
Approximation factor. Work on the event in Corollary 4.5, which has probability at least . Fix . Since the output index minimizes the estimated average distance, the average distance between the median measures and the output distribution is bounded by
where the first, third, and fourth inequalities follow from Corollary 4.5. Moreover, the median measures are close to P on average, since
where the last inequality uses Corollary 4.5. For every , use as the intermediate measure in the triangle inequality:
Averaging the triangle inequality through T rounds yields
Sample complexity. Each round draws one target sample, thus the algorithm uses exactly T target-sample calls, where .
Running time and space. As the analysis in Section 3.3 shows, each round takes time. The total running time is therefore .
AI Disclosure
ChatGPT was used extensively during the preparation of this work. The author suggested using a pointwise median to obtain an improper distribution with approximation factor 2 on the lower-bound instance of [AACS26]. Then, ChatGPT proposed combining weighted medians with multiplicative weight updates. ChatGPT and Claude also assisted with exposition and editing. The author takes full responsibility for the results, proofs, and references.
A Finding the weighted median in linear time
Ordinary order-statistic selection can be implemented deterministically in linear time by the median-of-medians algorithm of Blum et al. [BFP 73]. Partition the input into groups of five, sort each group, and recursively select a median of the group medians as a pivot. Partition around this pivot and recurse on the strict side containing the requested rank, unless the rank belongs to the values equal to the pivot. At least half the group medians lie weakly on either side of the pivot. Discarding the possibly incomplete group and the group containing the pivot loses at most two groups on either side. Each remaining full group contributes three values weakly on that side, so each strict side contains at most values, including when values coincide. Thus the worst-case cost satisfies, for sufficiently large m,
where the linear bound follows by induction since , with smaller instances handled directly. We use this selection procedure to find a weighted median as follows.
Lemma A.1 (Lower weighted quantile selection). Given real values with positive weights and a target mass satisfying , the smallest input value whose cumulative weight is at least can be found deterministically in worst-case time and working space.
Proof. Maintain an active set and a residual target satisfying . Select an ordinary median by count of the active values, namely an order statistic of rank , using the algorithm above. Write for its value, partition into
and compute and . Apply the following rules:
-
If , retain and leave unchanged.
-
If , return .
-
If , retain and replace by .
These rules preserve the residual-target invariant and the desired lower quantile. In particular, when , the target has already been reached strictly below z, so the first branch is necessary. In the last branch the discarded values all precede every remaining value, which justifies subtracting exactly their total weight.
Both strict sides of an ordinary median by count contain at most values. Therefore each nonterminal step at least halves the active-set size, including in the presence of ties. Selection, partitioning, and weight summation take operations per step, for a total of
The procedure terminates because each nonterminal branch strictly reduces the active set. Arrays for values, weights, and partitions, together with the recursive selection workspace, use stored numbers and indices.
For a density profile in round , apply Lemma A.1 with weights and target 1/2 to obtain . Then scan the entire original profile to compute the total weights strictly below, equal to, and strictly above , and scan once more to form all . These totals include the items discarded during selection. The scans cost , so computing the median and all signed tests costs , with no sorting of the full profile.
References
[AACS26] Anders Aamand, Maryam Aliakbarpour, Justin Y. Chen, and Sandeep Silwal. How fast can you find a good hypothesis? In Steve Hanneke and Tor Lattimore, editors, Proceedings of Thirty Ninth Conference on Learning Theory, volume 336 of Proceedings of Machine Learning Research, pages 1–2. PMLR, 29 Jun–03 Jul 2026. 1, 2, 11
[ABS24] Maryam Aliakbarpour, Mark Bun, and Adam Smith. Optimal hypothesis selection in (almost) linear time. Advances in Neural Information Processing Systems, 37:141490–141527, 2024. 1, 2
[AHK12] Sanjeev Arora, Elad Hazan, and Satyen Kale. The multiplicative weights update method: a meta-algorithm and applications. Theory of computing, 8(1):121–164, 2012. 2, 8
[Azu67] Kazuoki Azuma. Weighted sums of certain dependent random variables. Tohoku Mathematical Journal, Second Series, 19(3):357–367, 1967. 10
[BBK 22] Olivier Bousquet, Mark Braverman, Gillat Kol, Klim Efremenko, and Shay Moran. Statistically near-optimal hypothesis selection. In 2021 IEEE 62nd Annual Symposium on Foundations of Computer Science (FOCS), pages 909–919. IEEE, 2022. 1
[BFP 73] Manuel Blum, Robert W. Floyd, Vaughan R. Pratt, Ronald L. Rivest, Robert Endre Tarjan, et al. Time bounds for selection. J. Comput. Syst. Sci., 7(4):448–461, 1973. 11
[BKM19] Olivier Bousquet, Daniel Kane, and Shay Moran. The optimal approximation factor in density estimation. In Conference on Learning Theory, pages 318–341. PMLR, 2019. 1
[DL01] Luc Devroye and Gábor Lugosi. Combinatorial methods in density estimation, volume 1. Springer, 2001. 1, 2
[Hoe63] Wassily Hoeffding. Probability inequalities for sums of bounded random variables. Journal of the American statistical association, 58(301):13–30, 1963. 10
[MS08] Satyaki Mahalanabis and Daniel Stefankovic. Density estimation in linear time. In Rocco A. Servedio and Tong Zhang, editors, 21st Annual Conference on Learning Theory - COLT 2008, Helsinki, Finland, July 9-12, 2008, pages 503–512. Omnipress, 2008. 1, 2
[Yat85] Yannis G Yatracos. Rates of convergence of minimum distance estimators and kolmogorov's entropy. The Annals of Statistics, 13(2):768–774, 1985. 1, 2