Testing Shape Restrictions of Discrete Distributions

We study the question of testing structured properties (classes) of discrete distributions. Specifically, given sample access to an arbitrary distribution $D$ over $[n]$ and a property $\mathcal{P}$, the goal is to distinguish between $D\in\mathcal{P}$ and $\ell_1(D,\mathcal{P})>\varepsilon$. We develop a general algorithm for this question, which applies to a large range of"shape-constrained"properties, including monotone, log-concave, $t$-modal, piecewise-polynomial, and Poisson Binomial distributions. Moreover, for all cases considered, our algorithm has near-optimal sample complexity with regard to the domain size and is computationally efficient. For most of these classes, we provide the first non-trivial tester in the literature. In addition, we also describe a generic method to prove lower bounds for this problem, and use it to show our upper bounds are nearly tight. Finally, we extend some of our techniques to tolerant testing, deriving nearly-tight upper and lower bounds for the corresponding questions.


Introduction
Inferring information about the probability distribution that underlies a data sample is an essential question in Statistics, and one that has ramifications in every field of the natural sciences and quantitative research. In many situations, it is natural to assume that this data exhibits some simple structure because of known properties of the origin of the data, and in fact these assumptions are crucial in making the problem tractable. Such assumptions translate as constraints on the probability distribution -e.g., it is supposed to be Gaussian, or to meet a smoothness or "fat tail" condition (see e.g., [Man63,Hou86,TLSM95]).
As a result, the problem of deciding whether a distribution possesses such a structural property has been widely investigated both in theory and practice, in the context of shape restricted inference [BDBB72,SS01] and model selection [MP07]. Here, it is guaranteed or thought that the unknown distribution satisfies a shape constraint, such as having a monotone or log-concave probability density function [SN99,BB05,Wal09]. From a different perspective, a recent line of work in Theoretical Computer Science, originating from the papers of Batu et al. [BFR + 00, BFF + 01, GR00] has also been tackling similar questions in the setting of property testing (see [Ron08,Ron10,Rub12] for surveys on this field). This very active area has seen a spate of results and breakthroughs over the past decade, culminating in very efficient (both sample and time-wise) algorithms for a wide range of distribution testing problems [BDKR05, GMV06, AAK + 07, DDS + 13, CDVV14, AD15,DKN15b]. In many cases, this led to a tight characterization of the number of samples required for these tasks as well as the development of new tools and techniques, drawing connections to learning and information theory [VV10,VV11a,VV14].
In this paper, we focus on the following general property testing problem: given a class (property) of distributions P and sample access to an arbitrary distribution D, one must distinguish between the case that (a) D ∈ P, versus (b) D − D ′ 1 > ε for all D ′ ∈ P (i.e., D is either in the class, or far from it). While many of the previous works have focused on the testing of specific properties of distributions or obtained algorithms and lower bounds on a case-by-case basis, an emerging trend in distribution testing is to design general frameworks that can be applied to several property testing problems [Val11,VV11a,DKN15b,DKN15a]. This direction, the testing analog of a similar movement in distribution learning [CDSS13,CDSS14b,CDSS14a,ADLS15], aims at abstracting the minimal assumptions that are shared by a large variety of problems, and giving algorithms that can be used for any of these problems. In this work, we make significant progress in this direction by providing a unified framework for the question of testing various properties of probability distributions. More specifically, we describe a generic technique to obtain upper bounds on the sample complexity of this question, which applies to a broad range of structured classes. Our technique yields sample near-optimal and computationally efficient testers for a wide range of distribution families. Conversely, we also develop a general approach to prove lower bounds on these sample complexities, and use it to derive tight or nearly tight bounds for many of these classes.
Related work. Batu et al. [BKR04] initiated the study of efficient property testers for monotonicity and obtained (nearly) matching upper and lower bounds for this problem; while [AD15] later considered testing the class of Poisson Binomial Distributions, and settled the sample complexity of this problem (up to the precise dependence on ε). Indyk, Levi, and Rubinfeld [ILR12], focusing on distributions that are piecewise constant on t intervals ("t-histograms") described aÕ( √ tn/ε 5 )-sample algorithm for testing membership to this class. Another body of work by [BDKR05], [BKR04], and [DDS + 13] shows how assumptions on the shape of the distributions can lead to significantly more efficient algorithms. They describe such improvements in the case of identity and closeness testing as well as for entropy estimation, under monotonicity or k-modality constraints. Specifically, Batu et al. show in [BKR04] how to obtain a O log 3 n/ε 3 -sample tester for closeness in this setting, in stark contrast to the Ω n 2/3 general lower bound. Daskalakis et al. [DDS + 13] later gaveÕ( √ log n) andÕ(log 2/3 n)-sample testing algorithms for testing respectively identity and closeness of monotone distributions, and obtained similar results for k-modal distributions. Finally, we briefly mention two related results, due respectively to [BDKR05] and [DDS12a]. The first one states that for the task of getting a multiplicative estimate of the entropy of a distribution, assuming monotonicity enables exponential savings in sample complexity -O log 6 n , instead of Ω(n c ) for the general case. The second describes how to test if an unknown k-modal distribution is in fact monotone, using only O k/ε 2 samples. Note that the latter line of work differs from ours in that it presupposes the distributions satisfy some structural property, and uses this knowledge to test something else about the distribution; while we are given a priori arbitrary distributions, and must check whether the structural property holds. Except for the properties of monotonicity and being a PBD, nothing was previously known on testing the shape restricted properties that we study. Independently and concurrently to this work, Acharya, Daskalakis, and Kamath obtained a sample near-optimal efficient algorithm for testing log-concavity. 1 Moreover, for the specific problems of identity and closeness testing, 2 recent results of [DKN15b,DKN15a] describe a general algorithm which applies to a large range of shape or structural constraints, and yields optimal identity testers for classes of distributions that satisfy them. We observe that while the question they answer can be cast as a specialized instance of membership testing, our results are incomparable to theirs, both because of the distinction above (testing with versus testing for structure) and as the structural assumptions they rely on are fundamentally different from ours.

Results and Techniques
Upper Bounds. A natural way to tackle our membership testing problem would be to first learn the unknown distribution D as if it satisfied the property, before checking if the hypothesis obtained is indeed both close to the original distribution and to the property. Taking advantage of the purported structure, the first step could presumably be conducted with a small number of samples; things break down, however, in the second step. Indeed, most approximation results leading to the improved learning algorithms one would apply in the first stage only provide very weak guarantees, in the ℓ 1 sense. For this reason, they lack the robustness that would be required for the second part, where it becomes necessary to perform tolerant testing between the hypothesis and D -a task that would then entail a number of samples almost linear in the domain size. To overcome this difficulty, we need to move away from these global ℓ 1 closeness results and instead work with stronger requirements, this time in ℓ 2 norm.
At the core of our approach is an idea of Batu et al. [BKR04], which show that monotone distributions can be well-approximated (in a certain technical sense) by piecewise constant densities on a suitable interval partition of the domain; and leverage this fact to reduce monotonicity testing to uniformity testing on each interval of this partition. While the argument of [BKR04] is tailored specifically for the setting of monotonicity testing, we are able to abstract the key ingredients, and obtain a generic membership tester that applies to a wide range of distribution families. In more detail, we provide a testing algorithm which applies to any class of distributions which admits succinct approximate decompositions -that is, each distribution in the class can be well-approximated (in a strong ℓ 2 sense) by piecewise constant densities on a small number of intervals (we hereafter refer to this approximation property, formally defined in Definition 3.1, as (Succinctness); and extend the notation to apply to any class C of distributions for which all D ∈ C satisfy (Succinctness)). Crucially, the algorithm does not care about how these decompositions can be obtained: for the purpose of testing these structural properties we only need to establish their existence. Specific examples are given in the corollaries below. Informally, our main algorithmic result, informally stated (see Theorem 3.3 for a detailed formal statement), is as follows: We remark that the aforementioned sample upper bounds are information-theoretically nearoptimal in the domain size n (up to logarithmic factors). See Table 1 and the following subsection for the corresponding lower bounds. We did not attempt to optimize the dependence on the parameter ε, though a more careful analysis can lead to such improvements.
We stress that prior to our work, no non-trivial testing bound was known for most of these classes -specifically, our nearly-tight bounds for t-modal with t > 1, log-concave, concave, convex, MHR, and piecewise polynomial distributions are new. Moreover, although a few of our applications were known in the literature (theÕ √ n/ε 6 upper and Ω √ n/ε 2 lower bounds on testing monotonicity can be found in [BKR04], while the Θ n 1/4 sample complexity of testing PBDs was recently given 3 in [AD15], and the task of testing t-histograms is considered in [ILR12]), the crux here is that we are able to derive them in a unified way, by applying the same generic algorithm to all these different distribution families. We note that our upper bound for t-histograms (Corollary 1.4) also improves on the previousÕ √ tn/ε 5 -sample tester, as long as t =Õ n 1/3 /ε 2 . In addition to its generality, our framework yields much cleaner and conceptually simpler proofs of the upper and lower bounds from [AD15].
k-SIIRV Ω k 1/2 n 1/4 (Corollary 1.9) Lower Bounds. To complement our upper bounds, we give a generic framework for proving lower bounds against testing classes of distributions. In more detail, we describe how to reduce -under a mild assumption on the property C -the problem of testing membership to C ("does D ∈ C?") to testing identity to D * ("does D = D * ?"), for any explicit distribution D * in C. While these two problems need not in general be related, 4 we show that our reduction-based approach applies to a large number of natural properties, and obtain lower bounds that nearly match our upper bounds for all of them. Moreover, this lets us derive a simple proof of the lower bound of [AD15] on testing the class of PBDs. The reader is referred to Theorem 6.1 for the formal statement of our reduction-based lower bound theorem. In this section, we state the concrete corollaries we obtain for specific structured distribution families: log n samples, for ε 2 ≥ Cε 1 (where C > 2 is an absolute constant). Corollary 1.12. Tolerant testing of log-concavity, convexity, concavity, MHR, unimodality, and t-modality each require Ω 1 (ε 2 −ε 1 ) n log n samples (the latter for t = o(n)).

Corollary 1.13. Tolerant testing of the classes of Binomial and Poisson Binomial Distributions
On the scope of our results. We point out that our main theorem is likely to apply to many other classes of structured distributions, due to the mild structural assumptions it requires. However, we did not attempt here to be comprehensive; but rather to illustrate the generality of our approach. Moreover, for all properties considered in this paper the generic upper and lower bounds we derive through our methods turn out to be optimal up to at most polylogarithmic factors (with regard to the support size). The reader is referred to Table 1 for a summary of our results and related work.

Organization of the Paper
We start by giving the necessary background and definitions in Section 2, before turning to our main result, the proof of Theorem 1.1 (our general testing algorithm) in Section 3. In Section 4, we establish the necessary structural theorems for each classes of distributions considered, enabling us to derive the upper bounds of Table 1. Section 5 introduces a slight modification of our algorithm which yields stronger testing results for classes of distributions with small effective support, and use it to derive Corollary 1.5, our upper bound for Poisson Binomial distributions. Second, Section 6 contains the details of our lower bound methodology, and of its applications to the classes of Table 1. Finally, Section 6.2 is concerned with the extension of this methodology to tolerant testing, of which Section 7 describes a generic upper bound counterpart.

Definitions
We give here the formal descriptions of the classes of distributions involved in this work. Recall that a distribution D over [n] is monotone (non-increasing) if its probability mass function (pmf) satisfies D(1) ≥ D(2) ≥ . . . D(n). A natural generalization of the class M of monotone distributions is the set of t-modal distributions, i.e. distributions whose pmf can go "up and down" or "down and up" up to t times: 5 Definition 2.1 (t-modal). Fix any distribution D over [n], and integer t. D is said to have t modes if there exists a sequence i 0 < · · · < i t+1 such that either We call D t-modal if it has at most t modes, and write M t for the class of all t-modal distributions (omitting the dependence on n). The particular case of t = 1 corresponds to the set M 1 of unimodal distributions.
Definition 2.2 (Log-Concave). A distribution D over [n] is said to be log-concave if it satisfies the following conditions: (i) for any 1 ≤ i < j < k ≤ n such that D(i)D(k) > 0, D(j) > 0; and (ii) for all 1 < k < n, D(k) 2 ≥ D(k − 1)D(k + 1). We write L for the class of all log-concave distributions (omitting the dependence on n).

Definition 2.3 (Concave and Convex). A distribution D over [n]
is said to be concave if it satisfies the following conditions: (i) for any 1 ≤ i < j < k ≤ n such that D(i)D(k) > 0, D(j) > 0; and (ii) for all 1 < k < n such that D(k − 1)D(k + 1) > 0, 2D(k) ≥ D(k − 1) + D(k + 1); it is convex if the reverse inequality holds in (ii). We write K − (resp. K + ) for the class of all concave (resp. convex) distributions (omitting the dependence on n).
It is not hard to see that convex and concave distributions are unimodal; moreover, every concave distribution is also log-concave, i.e. K − ⊆ L. Note that in both Definition 2.2 and Definition 2.3, condition (i) is equivalent to enforcing that the distribution be supported on an interval.  It is known that every log-concave distribution is both unimodal and MHR (see e.g. [An96, Proposition 10]), and that monotone distributions are MHR. Two other classes of distributions have elicited significant interest in the context of density estimation, that of histograms (piecewise constant) and piecewise polynomial densities: Definition 2.5 (Piecewise Polynomials [CDSS14a]). A distribution D over [n] is said to be a tpiecewise degree-d distribution if there is a partition of [n] into t disjoint intervals I 1 , . . . , I t such that D(i) = p j (i) for all i ∈ I j , where each p 1 , . . . p t is a univariate polynomial of degree at most d. We write P t,d for the class of all t-piecewise degree-d distributions (omitting the dependence on n). (We note that t-piecewise degree-0 distributions are also commonly referred to as t-histograms, and write H t for P t,0 .) Finally, we recall the definition of the two following classes, which both extend the family of Binomial distributions BIN n : the first, by removing the need for each of the independent Bernoulli summands to share the same bias parameter.
Definition 2.6. A random variable X is said to follow a Poisson Binomial Distribution (with parameter n ∈ N) if it can be written as X = n k=1 X k , where X 1 . . . , X n are independent, nonnecessarily identically distributed Bernoulli random variables. We denote by PBD n the class of all such Poisson Binomial Distributions.
It is not hard to show that Poisson Binomial Distributions are in particular log-concave. One can generalize even further, by allowing each random variable of the summation to be integer-valued: Definition 2.7. Fix any k ≥ 0. We say a random variable X is a k-Sum of Independent Integer Random Variables (k-SIIRV) with parameter n ∈ N if it can be written as X = n j=1 X j , where X 1 . . . , X n are independent, non-necessarily identically distributed random variables taking value in {0, 1, . . . , k − 1}. We denote by k-SIIRV n the class of all such k-SIIRVs.

Tools from previous work
We first restate a result of Batu et al. relating closeness to uniformity in ℓ 2 and ℓ 1 norms to "overall flatness" of the probability mass function, and which will be one of the ingredients of the proof of Theorem 1.1: To check condition (b) above we shall rely on the following, which one can derive from the techniques in [DKN15b] and whose proof we defer to Appendix A: Lemma 2.9 (Adapted from [DKN15b, Theorem 11]). There exists an algorithm Check-Small-ℓ 2 which, given parameters ε, δ ∈ (0, 1) and c· |I|/ε 2 log(1/δ) independent samples from a distribution D over I (for some absolute constant c > 0), outputs either yes or no, and satisfies the following.
In particular, this implies that O 1/ε 2 samples suffice to learn a distribution up to ε in Kolmogorov distance.

The General Algorithm
In this section, we obtain our main result, restated below: There exists an algorithm TestSplittable which, given sampling access to an unknown distribution D over [n] and parameter ε ∈ (0, 1], can distinguish with probability 2/3 between (a) D ∈ P versus (b) ℓ 1 (D, P) > ε, for any property P that satisfies the above natural structural criterion (Succinctness). Moreover, for many such properties this algorithm is computationally efficient, and its sample complexity is optimal (up to logarithmic factors and the exact dependence on ε).
Intuition. Before diving into the proof of this theorem, we first provide a high-level description of the argument. The algorithm proceeds in 3 stages: the first, the decomposition step, attempts to recursively construct a partition of the domain in a small number of intervals, with a very strong guarantee. If the decomposition succeeds, then the unknown distribution D will be close (in ℓ 1 distance) to its "flattening" on the partition; while if it fails (too many intervals have to be created), this serves as evidence that D does not belong to the class and we can reject. The second stage, the approximation step, then learns this flattening of the distribution -which can be done with few samples since by construction we do not have many intervals. The last stage is purely computational, the projection step: where we verify that the flattening we have learned is indeed close to the class C. If all three stages succeed, then by the triangle inequality it must be the case that D is close to C; and by the structural assumption on the class, if D ∈ C then it will admit succinct enough partitions, and all three stages will go through.
Turning to the proof, we start by defining formally the "structural criterion" we shall rely on, before describing the algorithm at the heart of our result in Section 3.1. (We note that a modification of this algorithm will be described in Section 5, and will allow us to derive Corollary 1.5.) Further, if I(γ, D) is dyadic (i.e., each I k is of the form [j · 2 i + 1, (j + 1) · 2 i ] for some integers i, j, corresponding to the leaves of a recursive bisection of [n]), then C is said to be (γ, L)-splittable.
Proof. We will begin by proving a claim that for every partition I = {I 1 , I 2 , ...I L } of the interval [1, n] into L intervals, there exists a refinement of that partition which consists of at most L · log n dyadic intervals. So, it suffices to prove that every interval [a, b] ⊆ [1, n], can be partitioned in at most O(log n) dyadic intervals. Indeed, let ℓ be the largest integer such that 2 ℓ ≤ b−a 2 and let m be the smallest integer such that m · 2 ℓ ≥ a. If follows that m · 2 ℓ ≤ a + b−a 2 = a+b 2 and (m + 1) · 2 ℓ ≤ b. So, the interval I = [m · 2 ℓ + 1, (m + 1) · 2 ℓ ] is fully contained in [a, b] and has size at least b−a 4 . We will also use the fact that, for every ℓ ′ ≤ ℓ, Now consider the following procedure: Starting from right (resp. left) side of the interval I, we add the largest interval which is adjacent to it and fully contained in [a, b] and recurse until we cover the whole interval [(m + 1) · 2 ℓ + 1, b] (resp. [a, m · 2 ℓ ]). Clearly, at the end of this procedure, the whole interval [a, b] is covered by dyadic intervals. It remains to show that the procedure takes O(log n) steps. Indeed, using Equation 1, we can see that at least half of the remaining left or right interval is covered in each step (except maybe for the first 2 steps where it is at least a quarter). Thus, the procedure will take at most 2 log n + 2 = O(log n) steps in total. From the above, we can see that each of the L intervals of the partition I can be covered with O(log n) dyadic intervals, which completes the proof of the claim.
In order to complete the proof of the lemma, notice that the two conditions in Definition 3.1 are closed under taking subsets.

The algorithm
Theorem 1.1, and with it Corollary 1.2 and Corollary 1.3 will follow from the theorem below, combined with the structural theorems from Section 4: Theorem 3.3. Let C be a class of distributions over [n] for which the following holds.
1. C is (γ, L(γ, n))-splittable; 2. there exists a procedure ProjectionDist C which, given as input a parameter α ∈ (0, 1) and the explicit description of a distribution D over [n], returns yes if the distance ℓ 1 (D, C) to C is at most α/10, and no if ℓ 1 (D, C) ≥ 9α/10 (and either yes or no otherwise).

Proof of Theorem 3.3
We now give the proof of our main result (Theorem 3.3), first analyzing the sample complexity of Algorithm 1 before arguing its correctness. For the latter, we will need the following simple lemma from [ILR12], restated below: Algorithm 1 TestSplittable Require: Domain I (interval), sample access to D over I; subroutine ProjectionDist C Input: Parameters ε and function L C (·, ·).
3: while m I ≥ max c · √ |I| ε 2 log 1 δ , κm and at most L splits have been performed do 8: Run Check-Small-ℓ 2 (from Lemma 2.9) with parameters ε 40 and δ, using the samples of s belonging to I.
x j ∈ I }| is the number of the samples falling into I.

Sample complexity.
The sample complexity is immediate, and comes from Steps 4 and 20. The total number of samples is

Correctness.
Say an interval I considered during the execution of the "Decomposition" step is heavy if m I is big enough on Step 7, and light otherwise; and let H and L denote the sets of heavy and light intervals respectively. By choice of m and a union bound over all |I| 2 possible intervals, we can assume on one hand that with probability at least 9/10 the guarantees of Fact 3.4 hold simultaneously for all intervals considered. We hereafter condition on this event.
We first argue that if the algorithm does not reject in Step 13, then with probability at least 9/10 we have D − Φ(D, I) 1 ≤ ε/20. Indeed, we can write Let us bound the two terms separately.
• If I ′ ∈ H, then by our choice of threshold we can apply Lemma 2.9 with δ = 1 10L ; conditioning on all of the (at most L) events happening, which overall fails with probability at most 1/10 by a union bound, we get as Check-Small-ℓ 2 returned yes; and by Lemma 2.8 this implies D I ′ − U I ′ 1 ≤ ε/40.
mε 2 log 1 δ then m I ′ would have been big enough, and I ′ / ∈ L. Overall, for a sufficiently big choice of constant C > 0 in the definition of m; where we first used that |L| ≤ L, and then that I ′ ∈L Putting it together, this yields Soundness. By contrapositive, we argue that if the test returns ACCEPT, then (with probability at least 2/3) D is ε-close to C. Indeed, conditioning onD being ε/20-close to Φ(D, I), we get by the triangle inequality that Overall, this happens except with probability at most 1/10 + 1/10 + 1/10 < 1/3.

Completeness.
Assume D ∈ C. Then the choice of of γ and L ensures the existence of a good dyadic partition I(γ, D) in the sense of Definition 3.1. For any I in this partition for which (i) holds (D(I) ≤ γ L < κ 2 ), I will have m I m < κ and be kept as a "light leaf" (this by contrapositive of Fact 3.4 (ii)). For the other ones, (ii) holds: let I be one of these (at most L) intervals.
• If m I is too small on Step 7, then I is kept as "light leaf." • Otherwise, then by our choice of constants we can use Lemma 2.8 and apply Lemma 2.9 with δ = 1 10L ; conditioning on all of the (at most L) events happening, which overall fails with probability at most 1/10 by a union bound, Check-Small-ℓ 2 will output yes, as and I is kept as "flat leaf." Therefore, as I(γ, D) is dyadic the Decomposition stage is guaranteed to stop within at most L splits (in the worst case, it goes on until I(γ, D) is considered, at which point it succeeds). 6 Thus Step 13 passes, and the algorithm reaches the Approximation stage. By the foregoing discussion, this implies Φ(D, I) is ε/20-close to D (and hence to C);D is then (except with probability at most 1/10) ( ε 20 + ε 20 = ε 10 )-close to C, and the algorithm returns ACCEPT.

Structural Theorems
In this section, we show that a wide range of natural distribution families are succinctly decomposable, and provide efficient projection algorithms for each class.

Existence of Structural Decompositions
In more detail, we want to argue that if D is in the class, then a decomposition with at most L pieces is found by the algorithm. Since there is a dyadic decomposition with at most L pieces (namely, I(γ, D) = (I1, . . . , It)), it suffices to argue that the algorithm will never split one of the Ij's (as every single Ij will eventually be considered by the recursive binary splitting, unless the algorithm stopped recursing in this "path" before even considering Ij, which is even better). But this is the case by the above argument, which ensures each such Ij will be recognized as satisfying one of the two conditions for "good decomposition" (being either close to uniform in ℓ2, or having very little mass).
Note that this proof can already be found in [BKR04, Theorem 10], interwoven with the analysis of their algorithm. For the sake of being self-contained, we reproduce the structural part of their argument, removing its algorithmic aspects: Proof of Theorem 4.1. We define the I recursively as follows: is added as element of I (j+1) ("marked as leaf"); is added as element of I (j+1) ("marked as leaf"); (c) otherwise, bisect I (j) in I R as elements of I (j+1) . and repeat until convergence (that is, whenever the last item is not applied for any of the intervals). Clearly, this process is well-defined, and will eventually terminate (as (ℓ j ) j is a non-decreasing sequence of natural numbers, upper bounded by n). Let I = (I 1 , . . . , I ℓ ) (with I i = [a i , a i+1 )) be its outcome, so that the I i 's are consecutive intervals all satisfying either (a) or (b). As (b) clearly implies (ii), we only need to show that ℓ ≤ L; for this purpose, we shall leverage as in [BKR04] the fact that D is monotone to bound the number of recursion steps.
The recursion above defines a complete binary tree (with the leaves being the intervals satisfying (a) or (b), and the internal nodes the other ones). Let t be the number of recursion steps the process goes through before converging to I (height of the tree); as mentioned above, we have t ≤ log n (as we start with an interval of size n, and the length is halved at each step.). Observe further that if at any point an interval I nL , then it immediately (as well as all the I (j) k 's for k ≥ i by monotonicity) satisfies (a) and is no longer split ("becomes a leaf"). So at any j ≤ t, the number of intervals i j for which neither (a) nor (b) holds must satisfy where a k denotes the beginning of the k-th interval (again we use monotonicity to argue that the extrema were reached at the ends of each interval), so that i j ≤ 1 + log nL γ log(1+γ) . In particular, the total number of internal nodes is then This implies the same bound on the number of leaves ℓ. The same argument yields an analogue statement for t-modal distributions:

Corollary 4.3 (t-modality). For any t ≥ 1 and all
Corollary 4.4 (Log-concavity, concavity and convexity). For all γ > 0, the classes L, K − and K + of log-concave, concave and convex distributions on Proof. This is directly implied by Corollary 4.2, recalling that log-concave, concave and convex distributions are unimodal.
Proof. This follows from adapting the proof of [CDSS13], which establishes that every MHR distribution can be approximated in ℓ 1 distance by a O(log(n/ε)/ε)-histogram. For completeness, we reproduce their argument, suitably modified to our purposes, in Appendix B.
Proof. The last part of the statement is obvious, so we focus on the first claim. Observing that each of the t pieces of a distribution D ∈ P t,d can be subdivided in at most d + 1 intervals on which D is monotone (being degree-d polynomial on each such pieces), we obtain a partition of [n] into at most t(d + 1) intervals. D being monotone on each of them, we can apply an argument almost identical to that of Theorem 4.1 to argue that each interval can be further split into O(log 2 n/γ) subintervals, yielding a good decomposition with O(t(d + 1) log 2 n/γ) pieces.

Projection Step: computing the distances
This section contains details of the distance estimation procedures for these classes, required in the last stage of Algorithm 1. (Note that some of these results are phrased in terms of distance approximation, as estimating the distance ℓ 1 (D, C) to sufficient accuracy in particular yields an algorithm for this stage. ) We focus in this section on achieving the sample complexities stated in Corollary 1.2, Corollary 1.3, and Corollary 1.4. While almost all the distance estimation procedures we give in this section are efficient, running in time polynomial in all the parameters or even with only a polylogarithmic dependence on n, there are two exceptions -namely, the procedures for monotone hazard rate (Lemma 4.9) and log-concave (Lemma 4.10) distributions. We do describe computationally efficient procedures for these two cases as well in Section 4.2.1, at a modest additive cost in the sample complexity. A straightforward modification of the algorithm above (e.g., by adapting the underlying linear program to take as input the location m ∈ [ℓ] of the mode of the distribution; then trying all ℓ possibilities, running the subroutine ℓ times and picking the minimum value) results in a similar claim for unimodal distributions:  Lemma 4.10 (Log-concavity). There exists a (non-efficient) procedure ProjectionDist L that, on input n, ε, as well as the full specification of a distribution D on [n], distinguishes between Lemma 4.9 and Lemma 4.10. We here give a naive algorithm for these two problems, based on an exhaustive search over a (huge) ε-cover S of distributions over [n]. Essentially, S contains all possible distributions whose probabilities p 1 , . . . , p n are of the form jε/n, for j ∈ {0, . . . , n/ε} (so that |S| = O((n/ε) n )). It is not hard to see that this indeed defines an ε-cover of the set of all distributions, and moreover that it can be computed in time poly(|S|). To approximate the distance from an explicit distribution D to the class C (either MHR or L), it is enough to go over every element S of S, checking (this time, efficiently) if S − D 1 ≤ ε and if there is a distribution P ∈ C close to S (this time, pointwise, that is |P (i) − S(i)| ≤ ε/n for all i)which also implies S − P 1 ≤ ε and thus P − D 1 ≤ 2ε. The test for pointwise closeness can be done by checking feasibility of a linear program with variables corresponding to the logarithm of probabilities, i.e. x i ≡ ln P (i). Indeed, this formulation allows to rephrase the log-concave and MHR constraints as linear constraints, and pointwise approximation is simply enforcing that ln(S(i) − ε/n) ≤ x i ≤ ln(S(i) + ε/n) for all i. At the end of this enumeration, the procedure accepts if and only if for some S both S − D 1 ≤ ε and the corresponding linear program was feasible.
Lemma 4.11 (Piecewise Polynomials). There exists a procedure ProjectionDist P t,d that, on input n as well as the full specification of an ℓ-histogram D on [n], computes an approximation . Moreover, for the special case of t-histograms (d = 0) there exists a procedure ProjectionDist Ht , which, given inputs as above, computes an approximation ∆ of the distance ℓ 1 (D, H t ) such that where opt I is the optimal distance of D to any histogram on I. To get a 2-approximation of ℓ 1 (D, H t ), it thus suffices to find the minimum, over all possible partitionings I of [n] into t intervals, of the quantity D − Φ(D, I) 1 (which itself can be computed in time T = O(min(tℓ, n))). By a simple dynamic programming approach, this can be performed in time O tn 2 · T . The quadratic dependence on n, which follows from allowing the endpoints of the t intervals to be at any point of the domain, is however far from optimal and can be reduced to (t/ε) 2 , as we show below. For η > 0, define an η-granular decomposition of a distribution D over [n] to be a partition of Before proving it, we describe how this will enable us to get the desired time complexity for ProjectionDist Ht . Phrased differently, the claim above allows us to run our dynamic program using the O(1/η) endpoints of the O(1/η) instead of the n points of the domain, paying only an additive error O(tη). Setting η = ε 4t , the guarantee for ProjectionDist Ht follows.
Proof of Claim 4.12. Let J = (J 1 , . . . , J s ) be an η-granular decomposition of D, and H * ∈ H t be a histogram achieving opt = ℓ 1 (D, H t ). Denote further by I * = (I * 1 , . . . , I * t ) the partition of [n] corresponding to H * . Consider now the r ≤ t endpoints of the I * i 's that do not fall on one of the endpoints of the J i 's: let J i 1 , . . . , J ir be the respective intervals in which they fall (in particular, these cannot be singleton intervals), and S = ∪ r j=1 J i j their union. By definition of η-granularity, D(S) ≤ tη, and it follows that H * (S) ≤ tη + 1 2 opt. We define H from H * in two stages: first, we obtain a (sub)distribution H ′ by modifying H * on S, setting for each x ∈ J i j the value of H to be the minimum value (among the two options) that H * takes on J i j . H ′ is thus a t-histogram, and the endpoints of its intervals are endpoints of J as wished; but it may not sum to one. However, by construction we have that H ′ ([n]) ≥ 1 − H * (S) ≥ 1 − tη − 1 2 opt. Using this, we can finally define our t-histogram distribution H as the renormalization of H ′ . It is easy to check that H is a valid t-histogram on a coarsening of J , and as stated.
Turning now to ProjectionDist P t,d , we apply the same initial dynamic programming approach, which will result on a running time of O n 2 t · T , where T is the time required to estimate (to sufficient accuracy) the distance of a given (sub)distribution over an interval I onto the space P d of degree-d polynomials. Specifically, we will invoke the following result, adapted from [CDSS14a] to our setting: Theorem 4.13. Let p be a ℓ-histogram over [−1, 1). There is an algorithm ProjectSinglePoly(d, η) which runs in time poly(ℓ, d + 1, 1/η), and outputs a degree-d polynomial q which defines a pdf over The proof of this modification of [CDSS14a, Theorem 9] is deferred to Appendix C. Applying it as a blackbox with η set to O(ε/t) and noting that computing the ℓ 1 distance to our explicit distribution on a given interval of the degree-d polynomial returned incurs an additional O(n) factor, we obtain the claimed guarantee and running time.

Computationally Efficient Procedures for Log-concave and MHR Distributions
We now describe how to obtain efficient testing for the classes L and MHR -that is, how to obtain polynomial-time distance estimation procedures for these two classes, unlike the ones described in the previous section. At a very high-level, the idea is in both case to write down a linear program on variables related logarithmically to the probabilities we are searching, as enforcing the log-concave and MHR constraints on these new variables can be done linearly. The catch now becomes the ℓ 1 objective function (and, to a lesser extent, the fact that the probabilities must sum to one), now highly non-linear.
The first insight is to leverage the structure of log-concave (resp. monotone hazard rate) distributions to express this objective as slightly stronger constraints, specifically pointwise (1 ± ε)multiplicative closeness, much easier to enforce in our "logarithmic formulation." Even so, doing this naively fails, essentially because of a too weak distance guarantee between our explicit his-togramD and the unknown distribution we are trying to find: in the completeness case, we are only promised ε-closeness in ℓ 1 , while we would also require good additive pointwise closeness of the order ε 2 or ε 3 .
The second insight is thus to observe that we "almost" have this for free: indeed, if we do not reject in the first stage of the testing algorithm, we do obtain an explicit k-histogramD with the guarantee that D is ε-close to the distribution P to test. However, we also implicitly have another distributionD ′ that is ε/k-close to P in Kolmogorov distance: as in the recursive descent we take enough samples to use the DKW inequality (Theorem 2.10) with this parameter, i.e. an additive overhead of O(k/ε) samples (on top of theÕ( √ kn/ε 7/2 )). If we are willing to increase this overhead by just a small amount, that is to takeÕ max(k/ε,1/ε 4 ) , we can guarantee thatD ′ be alsoÕ ε 2 -close to P in Kolmogorov distance.
Combining these ideas yield the following distance estimation lemmas: Lemma 4.14 (Monotone Hazard Rate). There exists a procedure ProjectionDist * MHR that, on input n as well as the full specification of a k-histogram distribution D on [n] and of a ℓ-histogram distribution D ′ on [n], runs in time poly(n, 1/ε), and satisfies the following.
The proofs of these two lemmas are quite technical and deferred to Appendix C. With these in hand, a simple modification of our main algorithm (specifically, setting m =Õ(max( |I|/ε 3 L, L 2 /ε 2 , 1/ε c )) for c either 4 or 6 instead ofÕ(max( |I|/ε 3 L, L 2 /ε 2 )), to get the desired Kolmogorov distance guarantee; and providing the empirical histogram defined by these m samples along to the distance estimation procedure) suffices to obtain the following counterpart to Corollary 1.2: Corollary 4.16. The algorithm TestSplittable, after this modification, can efficiently test the classes of log-concave and monotone hazard rate (MHR) distributions, with respectivelyÕ √ n/ε 7/2 + 1/ε 4 andÕ √ n/ε 7/2 + 1/ε 6 samples.

Going Further: Reducing the Support Size
The general approach we have been following so far gives, out-of-the-box, an efficient testing algorithm with sample complexityÕ( √ n) for a large range of properties. However, this sample complexity can for some classes P be brought down a lot more, by taking advantage in a preprocessing step of good concentration guarantees of distributions in P.
As a motivating example, consider the class of Poisson Binomial Distributions (PBD). It is wellknown (see e.g. [KG71, Section 2]) that PBDs are unimodal, and more specifically that PBD n ⊆ L ⊆ M 1 . Therefore, using our generic framework we can test Poisson Binomial Distributions with O( √ n) samples. This is, however, far from optimal: as shown in [AD15], a sample complexity of Θ n 1/4 is both necessary and sufficient. The reason our general algorithm ends up making quadratically too many queries can be explained as follows. PBDs are tightly concentrated around their expectation, so that they "morally" live on a support of size m = O( √ n). Yet, instead of testing them on this very small support, in the above we still consider the entire range [n], and thus end up paying a dependence √ n -instead of √ m. If we could use that observation to first reduce the domain to the effective support of the distribution, then we could call our testing algorithm on this reduced domain of size O( √ n). In the rest of this section, we formalize and develop this idea, and in Section 5.2 will obtain as a direct application aÕ n 1/4 -query testing algorithm for PBD n .
Definition 5.1. Given ε > 0, the ε-effective support of a distribution D is the smallest interval I such that D(I) ≥ 1 − ε.
The last definition we shall require is of the conditioned distributions of a class C: Finally, we will require the following simple result: Proof. The first item is obvious. As for the second, let P ∈ C be any distribution with P (I) ≥ 1− ε 10 . By assumption, D − P 1 > ε: but we have, writing α = 1/10, We now proceed to state and prove our result -namely, efficient testing of structured classes of distributions with nice concentration properties. Call TestSplittable with I (providing simulated access to D I by rejection sampling, returning FAIL if the number of samples q from D I required by the subroutine is not obtained after O(q) samples from D), ProjectionDist C ε,I , parameters ε ′ def = 7ε 10 and L(·, ·).

Proof of Theorem 5.4
By the choice of m and the DKW inequality, with probability at least 23/24 the estimateD satisfies D −D Kol ≤ ε 60 . Conditioning on that from now on, we get that D(I) ≥D(I) − ε 30 ≥ 1 − ε 10 . Furthermore, denoting by j and k the two inner endpoints of J and K in Steps 4 and 5, we have D(J ∪ {j + 1}) ≥D(J ∪ {j + 1}) − ε 60 > ε 60 (similarly for D(K ∪ {k − 1})), so that I has size at most σ + 1, where σ is the ε 60 -effective support size of D. Finally, note that since D(I) = Ω(1) by our conditioning, the simulation of samples by rejection sampling will succeed with probability at least 23/24 and the algorithm will not output FAIL.
Sample complexity. The sample complexity is the sum of the O 1/ε 2 in Step 3 and the O(q) in Step 11. From Theorem 1.1 and the choice of I, this latter quantity is O max 1 where M = M (n, ε 60 ) and ℓ = L( ε 1200 , M (n, ε 60 )).

Correctness.
If D ∈ C, then by the setting of τ (set to be an upper bound on the ε 60 -effective support size of any distribution in C) the algorithm will go beyond Step 6. The call to TestSplittable will then end up in the algorithm returning ACCEPT in Step 12, with probability at least 2/3 by Lemma 5.3, Theorem 1.1 and our choice of parameters.
Similarly, if D is ε-far from C, then either its effective support is too large (and then the test on Step 6 fails), or the main tester will detect that its conditional distribution on I is 7ε 10 -far from C and output REJECT in Step 12.
Overall, in either case the algorithm is correct except with probability at most 1/24 + 1/24 + 1/3 = 5/12 (by a union bound). Repeating constantly many times and outputting the majority vote brings the probability of failure down to 1/3.

Application: Testing Poisson Binomial Distributions
In this section, we illustrate the use of our generic two-stage approach to test the class of Poisson Binomial Distributions. Specifically, we prove the following result: This is a direct consequence of Theorem 5.4 and the lemmas below. The first one states that, indeed, PBDs have small effective support: Fact 5.6. For any ε > 0, a PBD has ε-effective support of size O n log(1/ε) .
Proof. By an additive Chernoff Bound, any random variable X following a Poisson Binomial Distribution has Pr[ |X − EX| > γn ] ≤ 2e −2γ 2 n . Taking γ It is clear that if D ∈ PBD n (and therefore is unimodal), then for any interval I ⊆ [n] the conditional distribution D I is still unimodal, and thus the class of conditioned PBDs PBD ε,I n def = { D I : D ∈ PBD n , D(I) ≥ 1 − ε } falls under Corollary 4.2. The last piece we need to apply our generic testing framework is the existence of an algorithm to compute the distance between an (explicit) distribution and the class of conditioned PBDs. This is provided by our next lemma: Proof. The goal is to find a γ = Θ(ε)-approximation of the minimum value of i∈I P (i) P (I) − D(i) D(I) , subject to P (I) = i∈I P (i) ≥ 1 − ε and P ∈ PBD n . We first note that, given the parameters n ∈ N and p 1 , . . . , p n ∈ [0, 1] of a PBD P , the vector of (n + 1) probabilities P (0), . . . , P (n) can be obtained in time O n 2 by dynamic programming. Therefore, computing the ℓ 1 distance between D and any PBD with known parameters can be done efficiently. To conclude, we invoke a result of Diakonikolas, Kane, and Stewart, that guarantees the existence of a succinct (proper) cover of PBD n : Theorem 5.8 ([DKS15, Theorem 14] (rephrased)). For all n, γ > 0, there exists a set S γ ⊆ PBD n such that: (i) S γ is a γ-cover of PBD n ; that is, for all D ∈ PBD n there exists some D ′ ∈ S γ such that (iii) S γ can be computed in time n (1/γ) O(log 1/γ) and each D ∈ S γ is explicitly described by its set of parameters.
We further observe that the factor n in both the size of the cover and running time can be easily removed in our case, as we know a good approximation of the support size of the candidate PBDs. (That is, we only need to enumerate over a subset of the cover of [DKS15], that of the PBDs with effective support compatible with our distribution D.) Set γ def = ε 250 . Fix P ∈ PBD n such that P (I) ≥ 1 − ε, and Q ∈ S γ such that P − Q 1 ≤ γ. In particular, it is easy to see via the correspondence between ℓ 1 and total variation distance that |P (I) − Q(I)| ≤ γ/2. By a calculation analogue as in Lemma 5.3, we have where we used the fact that i / . By the triangle inequality, this implies that the minimum of P I − D I 1 over the distributions P of S ε with P (I) ≥ 1 − (ε + γ/2) will be within an additive O(ε) of ℓ 1 (D, PBD ε,I n ). The fact that the former can be done in time poly(n) · (1/ε) O(log 2 1/ε) concludes the proof.
As previously mentioned, this approximation guarantee for ℓ 1 (D, PBD ε,I n ) is sufficient for the purpose of Algorithm 1.

Reduction-based Lower Bound Approach
We now turn to proving converses to our positive results -namely, that many of the upper bounds we obtain cannot be significantly improved upon. As in our algorithmic approach, we describe for this purpose a generic framework for obtaining lower bounds.
In order to state our results, we will require the usual definition of agnostic learning. Recall that an algorithm is said to be a semi-agnostic learner for a class C if it satisfies the following. Given sample access to an arbitrary distribution D and parameter ε, it outputs a hypothesisD which (with high probability) does "almost as well as it gets": D), and c ≥ 1 is some absolute constant (if c = 1, the learner is said to be agnostic).
High-level idea. The motivation for our result is the observation of [BKR04] that "monotonicity is at least as hard as uniformity." Unfortunately, their specific argument does not generalize easily to other classes of distributions, making it impossible to extend it readily. The starting point of our approach is to observe that while uniformity testing is hard in general, it becomes very easy under the promise that the distribution is monotone, or even only close to monotone (namely, O 1/ε 2 samples suffice). This can give an alternate proof of the lower bound for monotonicity testing, via a different reduction: first, test if the unknown distribution is monotone; if it is, test whether it is uniform, now assuming closeness to monotone.
More generally, this idea applies to any class C which (a) contains the uniform distribution, and (b) for which we have a o( √ n)-sample agnostic learner L, as follows. Assuming we have a tester T for C with sample complexity o( √ n), define a uniformity tester as below.
• test if D ∈ C using T ; if not, reject (as U ∈ C, D cannot be uniform); • otherwise, agnostically learn D with L (since D is close to C), and obtain hypothesisD; • check offline ifD is close to uniform.
By assumption, T and L each use o( √ n) samples, so does the whole process; but this contradicts the lower bound of [BFR + 00, Pan08] on uniformity testing. Hence, T must use Ω( √ n) samples.
This "testing-by-narrowing" reduction argument can be further extended to other properties than to uniformity, as we show below: Theorem 6.1. Let C be a class of distributions over [n] for which the following holds: (i) there exists a semi-agnostic learner L for C, with sample complexity q L (n, ε, δ) and "agnostic constant" c; (ii) there exists a subclass C Hard ⊆ C such that testing C Hard requires q H (n, ε) samples. Suppose further that q L (n, ε, 1/10) = o(q H (n, ε)). Then, any tester for C must use Ω(q H (n, ε)) samples.
Proof. The above theorem relies on the reduction outlined above, which we rigorously detail here. Assuming C, C Hard , L as above (with semi-agnostic constant c ≥ 1), and a tester T for C with sample complexity q T (n, ε), we define a tester T Hard for C Hard . On input ε ∈ (0, 1] and given sample access to a distribution D on [n], T Hard acts as follows: • call T with parameters n, ε ′ c (where ε ′ def = ε 3 ) and failure probability 1/6, to ε ′ c -test if D ∈ C. If not, reject.
• otherwise, agnostically learn a hypothesisD for D, with L called with parameters n, ε ′ and failure probability 1/6; • check offline ifD is ε ′ -close to C Hard , accept if and only if this is the case.
We condition on both calls (to T and L) to be successful, which overall happens with probability at least 2/3 by a union bound. The completeness is immediate: if D ∈ C Hard ⊆ C, T accepts, and the hypothesisD satisfies D − D 1 ≤ ε ′ . Therefore, ℓ 1 (D, C Hard ) ≤ ε ′ , and T Hard accepts.
For the soundness, we proceed by contrapositive. Suppose T Hard accepts; it means that each step was successful. In particular, ℓ 1 (D, C) ≤ ε ′ /c; so that the hypothesis outputted by the agnostic learner satisfies D − D 1 ≤ c · opt + ε ′ ≤ 2ε ′ . In turn, since the last step passed and by a triangle inequality we get, as claimed, ℓ 1 (D, C Hard ) ≤ 2ε ′ + ℓ 1 (D, C Hard ) ≤ 3ε ′ = ε.
Similarly, we can use another result of [DDS12b] which shows how to agnostically learn Poisson Binomial Distributions withÕ 1/ε 2 samples. 8 Taking C Hard to be the single Bin(n, 1/2) distribution (along with the testing lower bound of [VV14]), this yields the following: Finally, we derive a lower bound on testing k-SIIRVs from the agnostic learner of [DDO + 13] (which has sample complexity poly(k, 1/ε) samples, independent of n): Corollary 1.9. There exist absolute constants c > 0 and ε 0 > 0 such that testing the class of k-SIIRV distributions requires Ω k 1/2 n 1/4 samples, for any k = o(n c ) and ε ≤ ε 0 . Corollary 1.9. To prove this result, it is enough by Theorem 6.1 to exhibit a particular k-SIIRV S such that testing identity to S requires this many samples. Moreover, from [VV14] this last part amounts to proving that the (truncated) 2/3-norm S − max −ε 0 2/3 of S is Ω k 1/2 n 1/4 (for some small ε 0 > 0). Our hard instance S will be defined as follows: it is defined as the distribution of X 1 + · · · + X n , where the X i 's are independent integer random variables uniform on {0, . . . , k − 1} (in particular, for k = 2 we get a Bin(n, 1/2) distribution). It is straightforward to verify that ES = n(k−1) 2 and σ 2 def = Var S = (k 2 −1)n 12 = Θ k 2 n ; moreover, S is log-concave (as the convolution of n uniform distributions). From this last point, we get that (i) the maximum probability of S, attained at its mode, is S ∞ = Θ(1/σ); and (ii) for every j in an interval I of length 2σ centered at this mode, S(j) ≥ Ω( S ∞ ). Putting this together, we get that the 2/3-norm (and similarly the truncated 2/3-norm) of S is lower bounded by j∈I S(j) 2/3 3/2 ≥ 2σ · Ω(1/σ) 2/3 3/2 = Ω σ 1/2 = Ω k 1/2 n 1/4 which concludes the proof.

Tolerant Testing
This lower bound framework from the previous section carries to tolerant testing as well, resulting in this analogue to Theorem 6.1:

Theorem 6.2. Let C be a class of distributions over [n] for which the following holds:
7 Specifically, these lower bounds hold as long as ε = Ω(1/n α ) for some absolute constant α > 0 (so that the sample complexity of the agnostic learner is indeed negligible in front of √ n/ε 2 ).
(i) there exists a semi-agnostic learner L for C, with sample complexity q L (n, ε, δ) and "agnostic constant" c; (ii) there exists a subclass C Hard ⊆ C such that tolerant testing C Hard requires q H (n, ε 1 , ε 2 ) samples for some parameters ε 2 > (4c + 1)ε 1 . Suppose further that q L (n, ε 2 − ε 1 , 1/10) = o (q H (n, ε 1 , ε 2 )). Then, any tolerant tester for C must use Ω(q H (n, ε 1 , ε 2 )) samples (for some explicit parameters ε ′ 1 , ε ′ 2 ). Proof. The argument follows the same ideas as for Theorem 6.1, up to the details of the parameters. Assuming C, C Hard , L as above (with semi-agnostic constant c ≥ 1), and a tolerant tester T for C with sample complexity q(n, ε 1 , ε 2 ), we define a tolerant tester T Hard for C Hard . On input 0 < ε 1 < ε 2 ≤ 1 with ε 2 > (4c + 1)ε 1 , and given sample access to a distribution D on [n], T Hard acts as follows. After setting ε ′ c and failure probability 1/6, to tolerantly test if D ∈ C. If ℓ 1 (D, C) > ε ′ 2 /c, reject. • otherwise, agnostically learn a hypothesisD for D, with L called with parameters n, ε ′ and failure probability 1/6; • check offline ifD is τ -close to C Hard , accept if and only if this is the case.
We condition on both calls (to T and L) to be successful, which overall happens with probability at least 2/3 by a union bound. We first argue completeness: assume ℓ 1 (D, C Hard ) ≤ ε 1 . This implies ℓ 1 (D, C) ≤ ε 1 , so that T accepts as ε 1 ≤ ε ′ 1 /c (which is the case because ε 2 > (4c + 1)ε 1 ). Thus, the hypothesisD satisfies and T Hard accepts. For the soundness, we again proceed by contrapositive. Suppose T Hard accepts; it means that each step was successful. In particular, ℓ 1 (D, C) ≤ ε ′ 2 /c; so that the hypothesis outputted by the agnostic learner satisfies D − D 1 ≤ c · opt + ε ′ ≤ ε ′ 2 + ε ′ . In turn, since the last step passed and by a triangle inequality we get, as claimed, ℓ 1 (D, C Hard ) ≤ ε ′ 2 + ε ′ + ℓ 1 (D, C Hard ) ≤ ε ′ 2 + ε ′ + τ < ε 2 . Observing that the overall sample complexity is q T (n, As before, we instantiate the general theorem to obtain specific lower bounds for tolerant testing of the classes we covered in this paper. That is, taking C Hard to be the singleton consisting of the uniform distribution (combined with the tolerant testing lower bound of [VV10]), and again from the semi-agnostic learners of [CDSS13,CDSS14a] (each with sample complexity either poly(1/ε) or poly(log n, 1/ε)), we obtain the following: Corollary 1.12. Tolerant testing of log-concavity, convexity, concavity, MHR, unimodality, and t-modality each require Ω 1 (ε 2 −ε 1 ) n log n samples (the latter for t = o(n)).
Similarly, we again turn to the class of Poisson Binomial Distributions, for which we can invoke as before theÕ 1/ε 2 -sample agnostic learner of [DDS12b]. As before, we would like to choose for C Hard the single Bin(n, 1/2) distribution; however, as no tolerant testing lower bound for this distribution exists -to the best of our knowledge -in the literature, we first need to establish the lower bound we will rely upon: Theorem 6.3. There exists an absolute constant ε 0 > 0 such that the following holds. Any algorithm which, given sampling access to an unknown distribution D on Ω and parameter ε ∈ (0, ε 0 ), distinguishes with probability at least 2/3 between (i) D − Bin(n, 1/2) 1 ≤ ε and (ii) D − Bin(n, 1/2) 1 ≥ 100ε must use Ω 1 ε √ n log n samples.
The proof relies on a reduction from tolerant testing of uniformity, drawing on a result of Valiant and Valiant [VV10]; for the sake of conciseness, the details are deferred to Appendix D. With Theorem 6.3 in hand, we can apply Theorem 6.2 to obtain the desired lower bound: We observe that both Corollary 1.12 and Corollary 1.13 are tight (with regard to the dependence on n), as proven in the next section (Section 7).

A Generic Tolerant Testing Upper Bound
To conclude this work, we address the question of tolerant testing of distribution classes. In the same spirit as before, we focus on describing a generic approach to obtain such bounds, in a clean conceptual manner. The most general statement of the result we prove in this section is stated below, which we then instantiate to match the lower bounds from Section 6.2: Theorem 7.1. Let C be a class of distributions over [n] for which the following holds: (i) there exists a semi-agnostic learner L for C, with sample complexity q L (n, ε, δ) and "agnostic constant" c; (ii) for any η ∈ [0, 1], every distribution in C has η-effective support of size at most M (n, η). Then, there exists an algorithm that, for any fixed κ > 1 and on input ε 1 , ε 2 ∈ (0, 1) such that ε 2 ≥ Cε 1 , has the following guarantee (where C > 2 depends on c and κ only). The algorithm takes O 1 (ε 2 −ε 1 ) 2 m log m + q L (n, ε 2 −ε 1 κ , 1 10 ) samples (where m = M (n, ε 1 )), and with probability at least 2/3 distinguishes between (a) ℓ 1 (D, C) ≤ ε 1 and (b) ℓ 1 (D, C) > ε 2 . (Moreover, one can take C = (1 + (5c + 6) κ κ−1 ).) Corollary 1.10. Tolerant testing of log-concavity, convexity, concavity, MHR, unimodality, and tmodality can be performed with O 1 (ε 2 −ε 1 ) 2 n log n samples, for ε 2 ≥ Cε 1 (where C > 2 is an absolute constant).
Applying now the theorem with M (n, ε) = n log(1/ε) (as per Corollary 5.5), we obtain an improved upper bound for Binomial and Poisson Binomial distributions:

Corollary 1.11. Tolerant testing of the classes of Binomial and Poisson Binomial Distributions
High-level idea. Somewhat similar to the lower bound framework developed in Section 6, the gist of the approach is to reduce the problem of tolerant testing membership of D to the class C to that of tolerant testing identity to a known distribution -namely, the distributionD obtained after trying to agnostically learn D. Intuitively, an agnostic learner for C should result in a good enough hypothesisD (i.e.,D close enough to both D and C) when D is ε 1 -close to C; but output aD that is significantly far from either D or C when D is ε 2 -far from C -sufficiently for us to be able to tell. Besides the many technical details one has to control for the parameters to work out, one key element is the use of a tolerant testing algorithm for closeness of two distributions due to [VV11b], whose (tight) sample complexity scales as n/ log n for a domain of size n. In order to get the right dependence on the effective support (required in particular for Corollary 1.11), we have to perform a first test to identify the effective support of the distribution and check its size, in order to only call this tolerant closeness testing algorithm on this much smaller subset. (This additional preprocessing step itself has to be carefully done, and comes at the price of a slightly worse constant C = C(c, κ) in the statement of the theorem.)

Proof of Theorem 7.1
As described in the preceding section, the algorithm will rely on the ability to perform tolerant testing of equivalence between two unknown distributions (over some known domain of size m). This is ensured by an algorithm of Valiant and Valiant, restated below: For the proof, we will also need this fact, similar to Lemma 5.3, which relates the distance of two distributions to that of their conditional distributions on a subset of the domain: Proof. To establish the first item, write: where we used the fact that |P (I) − D(I)| ≤ d TV (D, P ) = 1 2 D − P 1 . Turning now to the second item, we have: With these two ingredients, we are in position to establish our theorem: Proof of Theorem 7.1. The algorithm proceeds as follows, where we set ε (1) using O( 1 ε 2 ) samples, get (with probability at least 1 − 1/10, by Theorem 2.10) a distributioñ D ε 2 -close to D in Kolmogorov distance; and let I ⊆ [n] be the smallest interval such that (2) invoke L on D with parameters ε and failure probability 1 10 , to obtain a hypothesisD; (3) call E (from Theorem 7.2) on D I ,D I with parameter ε 6 to get an estimate∆ of D I −D I 1 ; (4) output REJECT ifD(I) < 1 − τ ; (5) compute "offline" (an estimate accurate within ε of) ℓ 1 (D, C), denoted ∆; (6) output REJECT is ∆ +∆ > θ, and output ACCEPT otherwise. The claimed sample complexity is immediate from Steps (2) and (3), along with Theorem 7.2. Turning to correctness, we condition on both subroutines meeting their guarantee (i.e., D −D 1 ≤ c·opt+ε and D −D 1 ∈ [∆−ε,∆+ε]), which happens with probability at least 8/10−1/ poly(n) ≥ 3/4 by a union bound.
Finally, the testing algorithm defined above is computationally efficient as long as both the learning algorithm (Step (2)) and the estimation procedure (Step (5)) are.
Proof. To do so, we first describe an algorithm that distinguishes between D − U 2 2 ≥ ε 2 /n and D − U 2 2 < ε 2 /(2n) with probability at least 2/3, using C · √ n ε 2 samples. Boosting the success probability to 1 − δ at the price of a multiplicative log 1 δ factor can then be achieved by standard techniques.
Similarly as in the proof of Theorem 11 (whose algorithm we use, but with a threshold τ def = 3 4 m 2 ε 2 n instead of 4m √ n ), define the quantities and Z def = n k=1 Z k , where the X k 's (and thus the Z k 's) are independent by Poissonization, and X k ∼ Poisson(mD(k)). It is not hard to see that 2 . Furthermore, we also get (after expanding and since n k=1 ∆ k = 0).

B Proof of Theorem 4.5
In this section, we prove our structural result for MHR distributions, Theorem 4.5: Proof. We reproduce and adapt the argument of [CDSS13, Section 5.1] to meet our definition of decomposability (which, albeit related, is incomparable to theirs). First, we modify the algorithm at the core of their constructive proof, in Algorithm 3: note that the only two changes are in Steps 2 and 3, where we use parameters respectively γ n and γ n 2 . Following the structure of their proof, we write Q = {I 1 , . . . , We immediately obtain the analogues of their Lemmas 5.2 and 5.3: 9 For any sequence x = (x1, . . . , xn) ∈ R n , p > 0 → x p is non-increasing. In particular, for 0 < p ≤ q < ∞, To see why, one can easily prove that if x p = 1, then x q q ≤ 1 (bounding each term |xi| q ≤ |xi| p ), and therefore x q ≤ 1 = x p . Next, for the general case, apply this to y = x/ x p , which has unit ℓp norm, and conclude by homogeneity of the norm. Let j ∈ J bet the smallest integer such that D(j) / ∈ [ 1 1+γ , 1 + γ]D(i). If no such j exists, let I ′′′ ← J; otherwise let I ′′′ ← {i, . . . , j − 1}.

Lemma B.2.
Step 4 of Algorithm 3 adds at most O 1 ε log n ε intervals to Q.
Sketch. This derives from observing that now D(I ∪ I ′ ) ≥ γ/n, which as in [CDSS13, Lemma 5.3] in turn implies 1 ≥ γ n (1 + γ) |Q ′ |−1 so that |Q ′ | = O 1 ε log n ε . Again following their argument, we also get by combining Lemma B.1 with the fact that D(a |Q|+1 ≤ 1 and that by construction D(a i ) ≥ γ/n 2 , we get But since each term in the product is at least (1 + γ) (by construction of Q and the definition of Q ′′ ), this leads to (1 + γ) |Q ′′ | ≤ n 3 γ and thus |Q ′′ | = O 1 ε log n ε as well.
It remains to show that Q∪{I, I ′ , I ′′ } is indeed a good decomposition of [n] for D, as per Definition 3.1. Since by construction every interval in Q satisfies item (ii), we only are left with the case of I, I ′ and I ′′ . For the first two, as they were returned by Right-Interval either (a) they are singletons, in which case item (ii) trivially holds; or (b) they have at least two elements, in which case they have probability mass at most γ n (by the choice of parameters for Right-Interval) and thus item (i) is satisfied. Finally, it is immediate to see that by construction D(I ′′ ) ≤ n · γ/n 2 = γ/n, and item (i) holds in this case as well.

C Proofs from Section 4
This section contains the proofs omitted from Section 4, namely the distance estimation procedures for t-piecewise degree-d (Theorem 4.13), monotone hazard rate (Lemma 4.14), and log-concave distributions (Lemma 4.15).

C.1 Proof of Theorem 4.13
In this section, we prove the following: Let p be a ℓ-histogram over [−1, 1). There is an algorithm ProjectSinglePoly(d, ε) which runs in time poly(ℓ, d + 1, 1/ε), and outputs a degree-d polynomial q which defines a pdf over As mentioned in Section 4, the proof of this statement is a rather straightforward adaption of the proof of [CDSS14a, Theorem 9], with two differences: first, in our setting there is no uncertainty nor probabilistic argument due to sampling, as we are provided with an explicit description of the histogram p. Second, Chan et al. require some "well-behavedness" assumption on the distribution p (for technical reasons essentially due to the sampling access), that we remove here. Besides these two points, the proof is almost identical to theirs, and we only reproduce (our modification of) it here for the sake of completeness. (Any error introduced in the process, however, is solely our responsibility.) Proof. Some preliminary definitions will be helpful: Definition C.2 (Uniform partition). Let p be a subdistribution on an interval I ⊆ [−1, 1). A partition I = {I 1 , . . . , I ℓ } of I is (p, η)-uniform if p(I j ) ≤ η for all 1 ≤ j ≤ ℓ.
We will also use the following notation: For this subsection, let I = [−1, 1) (I will denote a subinterval of [−1, 1) when the results are applied in the next subsection). We write f (I) 1 to denote I |f (x)|dx, and we write d TV (I) (p, q) to denote p − q (I) 1 /2. We write opt (I) 1,d to denote the infimum of the distance p − g (I) 1 between p and any degree-d subdistribution g on I that satisfies g(I) = p(I).
The key step of ProjectSinglePoly is Step 2 where it calls the FindSinglePoly procedure. In this procedure T i (x) denotes the degree-i Chebychev polynomial of the first kind. The function FindSinglePoly should be thought of as the CDF of a "quasi-distribution" f ; we say that f = F ′ is a "quasi-distribution" and not a bona fide probability distribution because it is not guaranteed to be non-negative everywhere on [−1, 1).
Step 2 of FindSinglePoly processes f slightly to obtain a polynomial q which is an actual distribution over [−1, 1).
The rest of this subsection gives the proof of Theorem C.1. The claimed running time bound is obvious (the computation is dominated by solving the poly(d, 1/ε)-size LP in ProjectSingle-Poly, with an additional term linear in ℓ when partitioning [−1, 1) in the initial first step), so it suffices to prove correctness.
Before launching into the proof we give some intuition for the linear program. Intuitively F (x) represents the cdf of a degree-d polynomial distribution f where f = F ′ . Constraint (a) captures the endpoint constraints that any cdf must obey if it has the same total weight as p. Intuitively, constraint (b) ensures that for each interval [i j , i k ), the value F (i k )−F (i j ) (which we may alternately write as f ([i j , i k ))) is close to the weight p([i j , i k )) that the distribution puts on the interval. Recall that by assumption p is opt 1,d -close to some degree-d polynomial r. Intuitively the variable w ℓ represents [i ℓ ,i ℓ+1 ) (r − p) (note that these values sum to zero by constraint (c)(4), and y ℓ represents the absolute value of w ℓ (see constraint (c)(5)). The value τ , which by constraint (c)(6) is at least the sum of the y ℓ 's, represents a lower bound on opt 1,d . The constraints in (d) and (e) reflect the fact that as a cdf, F should be bounded between 0 and 1 (more on this below), and the (f) constraints reflect the fact that the pdf f = F ′ should be everywhere nonnegative (again more on this below).
We begin by observing that ProjectSinglePoly calls FindSinglePoly with input parameters that satisfy FindSinglePoly's input requirements: (I) the non-singleton intervals I 0 , . . . , I z−1 are (p, η)-uniform; and (II) the singleton intervals each have weight at least η 10 . We then proceed to show that, from there, FindSinglePoly's LP is feasible and has a highquality optimal solution. Lemma C.3. Suppose p is an ℓ-histogram over [−1, 1), so that conditions (I) and (II) above hold; then the LP defined in Step 1 of FindSinglePoly is feasible; and the optimal solution τ is at most opt 1,d .
Proof. As above, let r be a degree-d polynomial pdf such that opt 1,d = p − r 1 and r(I) = p(I).We exhibit a feasible solution as follows: take F to be the cdf of r (a degree d polynomial). Take w ℓ to be [i ℓ ,i ℓ+1 ) (r − p), and take y ℓ to be |w ℓ |. Finally, take τ to be 0≤ℓ<z y ℓ .
We first argue feasibility of the above solution. We first take care of the easy constraints: since F is the cdf of a subdistribution over I it is clear that constraints (a) and (e) are satisfied, and since both r and p are pdfs with the same total weight it is clear that constraints (c)(4) and (f) are both satisfied. Constraints (c)(5) and (c)(6) also hold. So it remains to argue constraints (b) and (d).
To see that constraint (d) is satisfied we recall some of the analysis of Arora and Khot [AK03, Section 3]. This analysis shows that since F is a cumulative distribution function (and in particular Algorithm 5 FindSinglePoly Require: degree parameter d; error parameter ε; parameter η; (p, η)-uniform partition I I = {I 1 , . . . , I z } of interval I into z intervals such that √ εz · η ≤ ε/2; a subdistribution p on I Ensure: a number τ and a degree-d subdistribution q on I such that q(I) = p(I), minimize τ subject to the following constraints: (3) −y ℓ ≤ w ℓ ≤ y ℓ for all 0 ≤ ℓ < z, where J is a set of O (d + 1) 6 equally spaced points across [−1, 1); where K is a set of O((d + 1) 2 /ε) equally spaced points across [−1, 1).
. Output q as the hypothesis pdf.
a function bounded between 0 and 1 on I) each of its Chebychev coefficients is at most √ 2 in magnitude.
Having established that with high probability the LP is indeed feasible, henceforth we let τ denote the optimal solution to the LP and F , f , w ℓ , c i , y ℓ denote the values in the optimal solution. A simple argument (see e.g. the proof of [AK03, Theorem 8]) gives that F ∞ ≤ 2. Given this bound on F ∞ , the Bernstein-Markov inequality implies that . Together with (f) this implies that f (z) ≥ −ε/2 for all z ∈ [−1, 1). Consequently q(z) ≥ 0 for all z ∈ [−1, 1), and We sketch the argument that we shall use to bound p − q 1 . A key step in achieving this bound is to bound the · A distance between f and p m + w where A = A d+1 is the class of all unions of d + 1 intervals and w is a function based on the w ℓ values (see (9) below). If we can bound . From this point a simple argument (Proposition C.5) gives that p − q 1 ≤ p − f 1 + O(ε), which gives the theorem.
We will use the following lemma that translates (I, η, ε)-inequalities into a bound on A d+1 distance. Proof. To analyze p − h A d+1 , consider any union of d + 1 disjoint non-overlapping intervals S = J 1 ∪ · · · ∪ J d+1 . We will bound p − h A d+1 by bounding |p(S) − h(S)|.
We lengthen intervals in S slightly to obtain Indeed, consider any interval of the form J = [i ℓ , i ℓ+1 ) such that J ∩ S = J ∩ T (in particular, such an interval cannot be one of the singletons). We have where the first inequality uses non-negativity of p and the second inequality follows from the bound p([i ℓ , i ℓ+1 )) ≤ η. The (I, η, ε)-inequalities (between h and p) implies that the inequalities in (8) also hold with h in place of p. Now (7) follows by adding (8) across all J = [i ℓ , i ℓ+1 ) such that J ∩ S = J ∩ T (there are at most 2(d + 1) such intervals J), since each interval J j in S can change at most two such J's when lengthened. Now rewrite T as a disjoint union of by (I, η, ε)-inequalities between p and h. Now observing that that 0 ≤ L 1 ≤ R 1 · · · ≤ L s ≤ R s ≤ t = O((d + 1)/ε), we get that the largest possible value of s j=1 R j − L j is √ sz ≤ (d + 1)z, so the RHS of (7) is at most O((d + 1)η) + (d + 1)zεη, as desired.
Recall from above that F , f , w ℓ , c i , y ℓ , τ denote the values in the optimal solution. We claim that where w is the subdistribution which is constant on each [i ℓ , i ℓ+1 ) and has weight w ℓ there, so in particular w 1 ≤ τ ≤ opt 1,d . Indeed, this equality follows by applying Lemma C.4 with h = f − w. The lemma requires h and p to satisfy (I, η, ε)-inequalities, which follows from constraint (b) ((I, η, ε)-inequalities between p + w and f ) and observing that ( We have also used η = Θ(ε/(d + 1)) to bound the error term of the lemma by O(ε). Next, by the triangle inequality we have (writing A for A d+1 ) The last term on the RHS has just been shown to be O(ε). The first term is bounded by Altogether, we get that r − f A ≤ opt 1,d + O(ε).
Since r and f are degree d polynomials, . Finally, we turn our quasidistribution f which has value ≥ −ε/2 everywhere into a distribution q (which is nonnegative), by redistributing the weight. The following simple proposition bounds the error incurred.

Proposition C.5. Let f and p be any sub-quasidistribution on
We now have p − q 1 ≤ p − f 1 +O(ε) by Proposition C.5, concluding the proof of Theorem C.1.

C.2 Proof of Lemma 4.14
Lemma 4.14 (Monotone Hazard Rate). There exists a procedure ProjectionDist * MHR that, on input n as well as the full specification of a k-histogram distribution D on [n] and of a ℓ-histogram distribution D ′ on [n], runs in time poly(n, 1/ε), and satisfies the following.
Proof. For convenience, let α def = ε 3 ; we also write [i, j] instead of {i, . . . , j}. First, we note that it is easy to reduce our problem to the case where, in the completeness case, we have P ∈ MHR such that D − P 1 ≤ 2ε and D − P Kol ≤ 2α; while in the soundness case ℓ 1 (D, MHR) ≥ 99ε. Indeed, this can be done with a linear program on poly(k, ℓ) variables, asking to find a (k + ℓ)-histogram D ′′ on a refinement of D and D ′ minimizing the ℓ 1 distance to D, under the constraint that the Kolmogorov distance to D ′ be bounded by ε. (In the completeness case, clearly a feasible solution exists, as P is one.) We therefore follow with this new formulation: either (a) D is ε-close to a monotone hazard rate distribution P (in ℓ 1 distance) and D is α-close to P (in Kolmogorov distance); and We then proceed by observing the following easy fact: suppose P is a MHR distribution on [n], i.e. such that the quantity h i def = P (i) n j=i P (i) , i ∈ [n] is non-increasing. Then, we have and there is a bijective correspondence between P and (h i ) i∈ [n] .
We will write a linear program with variables y 1 , . . . , y n , with the correspondence y i def = ln(1−h i ). Note that with this parameterization, we get that if the (y i ) i∈ [n] correspond to a MHR distribution P , then for i ∈ We focus first on the completeness case, to provide intuition for the linear program. Suppose there exists P ∈ MHR such P ∈ MHR such that D − P 1 ≤ ε and D ′ − P Kol ≤ α. The linear program. Let T and S be respectively the sets of "light" and "heavy" points, defined as T = i ∈ {1, . . . , b} : D(i) ≤ ε 2 and S = i ∈ {1, . . . , b} : D(i) > ε 2 , where b is as above. (In particular, |S| ≤ 1/ε 2 .)

Completeness.
Suppose P ∈ MHR is as promised. In particular, by the Kolmogorov distance assumption we know that every i ∈ T has P (i) ≤ ε 2 + 2α < 2ε 2 .
• For any i ∈ T , we have that P (i) P [i,n] ≤ 2ε 2 (1−ε)ε ≤ 4ε, and Soundness. Assume a feasible solution to the linear program is found. We argue that this implies D is O(ε)-close to some MHR distribution, namely to the distribution obtained by renormalizing P .
In order to do so, we bound separately the ℓ 1 distance between D andP , from I, S, and T . First, i∈I D(i) −P (i) = i∈I D(i) ≤ ε 2 by construction. For i ∈ T , we have D(i) D[i,n] ≤ ε, and where the last inequality follows from Constraint (16).
To analyze the contribution from S, we observe that Constraint (18) implies that, for any i ∈ S, which combined with Constraint (14) guarantees which in turn implies that P (i) − D(i) ≤ 3εP (i) + 2α. Recalling that |S| ≤ 1 ε 2 and α = ε 3 , this yields i∈S D(i) −P (i) ≤ 3ε i∈SP (i) + 2ε ≤ 3ε(1 + ε) + 2ε ≤ 8ε. Summing up, we get n i=1 D(i) −P (i) ≤ 30ε which finally implies by the triangle inequality that the ℓ 1 distance between D and the normalized version ofP (a valid MHR distribution) is at most 32ε.

Running time.
The running time is immediate, from executing the two linear programs on poly(n, 1/ε) variables and constraints.

C.3 Proof of Lemma 4.15
Lemma 4.15 (Log-concavity). There exists a procedure ProjectionDist * L that, on input n as well as the full specifications of a k-histogram distribution D on [n] and a ℓ-histogram distribution D ′ on [n], runs in time poly(n, k, ℓ, 1/ε), and satisfies the following.
Proof. We set α def = ε 2 log 2 (1/ε) , β def = ε 2 log(1/ε) , and γ def = ε 2 10 (so that α ≪ β ≪ γ ≪ ε), Given the explicit description of a distribution D on [n], which a k-histogram over a partition I = (I 1 , . . . , I k ) of [n] with k = poly(log n, 1/ε) and the explicit description of a distribution D ′ on [n], one must efficiently distinguish between: (a) D is ε-close to a log-concave P (in ℓ 1 distance) and D ′ is α-close to P (in Kolmogorov distance); and (b) D is 100ε-far from log-concave. If we are willing to pay an extra factor of O(n), we can assume without loss of generality that we know the mode of the closest log-concave distribution (which is implicitly assumed in the following: the final algorithm will simply try all possible modes).
Outline. First, we argue that we can simplify to the case where D is unimodal. Then, reduce to the case where where D and D ′ are only one distribution, satisfying both requirements from the completeness case. Both can be done efficiently (Section C.3.1), and make the rest much easier. Then, perform some ad hoc partitioning of [n], using our knowledge of D, intoÕ 1/ε 2 pieces such that each piece is either a "heavy" singleton, or an interval I with weight very close (multiplicatively) to D(I) under the target log-concave distribution, if it exists (Section C.3.2). This in particular simplifies the type of log-concave distribution we are looking for: it is sufficient to look for distributions putting that very specific weight on each piece, up to a (1 + o(1)) factor. Then, in Section C.3.3, we write and solve a linear program to try and find such a "simplified" log-concave distribution, and reject if no feasible solution exists.
Note that the first two sections allow us to argue that instead of additive (in ℓ 1 ) closeness, we can enforce constraints on multiplicative (within a (1 + ε) factor) closeness between D and the target log-concave distribution. This is what enables a linear program with variables being the logarithm of the probabilities, which plays very nicely with the log-concavity constraints.
We will require the following result of Chan, Diakonikolas, Servedio, and Sun: • If D is ε-close to a log-concave distribution P as above, then it is in particular ε-close to unimodal and we do not reject. Moreover, by the triangle inequality D − P 1 ≤ 2ε and D − P Kol ≤ 2α.
• If D is 100ε-far from log-concave and we do not reject, then ℓ 1 (D, L) ≥ 99ε.
Reducing to D = D ′ . First, we note that it is easy to reduce our problem to the case where, in the completeness case, we have P ∈ L such that D − P 1 ≤ 4ε and D − P Kol ≤ 4α; while in the soundness case ℓ 1 (D, L) ≥ 97ε. Indeed, this can be done with a linear program on poly(k, ℓ) variables and constraints, asking to find a (k + ℓ)-histogram D ′′ on a refinement of D and D ′ minimizing the ℓ 1 distance to D, under the constraint that the Kolmogorov distance to D ′ be bounded by 2α. (In the completeness case, clearly a feasible solution exists, as (the flattening on this (k + ℓ)-interval partition) of P is one.) We therefore follow with this new formulation: either (a) D is 4ε-close to a log-concave P (in ℓ 1 distance) and D is 4α-close to P (in Kolmogorov distance); and (b) D is 97ε-far from log-concave; where D is a (k + ℓ)-histogram.
This way, we have reduced the problem to a slightly more convenient one, that of Section C.3.2.
Reducing to knowing the support [a, b]. The next step is to compute a good approximation of the support of any target log-concave distribution. This is easily obtained in time O(k) as the interval {a, · · · , b} such that Any log-concave distribution that is α-close to D must include {a, · · · , b} in its support, since otherwise the ℓ 1 distance between D and P is already greater than α. Conversely, if P is a logconcave distribution α-close to D, it is easy to see that the distribution obtained by setting P to be zero outside {a, · · · , b} and renormalizing the result is still log-concave, and O(α)-close to D.

C.3.2 Step 2
Given the explicit description of a unimodal distribution D on [n], which a k-histogram over a partition I = (I 1 , . . . , I k ) of [n] with k = poly(log n, 1/ε), one must efficiently distinguish between: (a) D is ε-close to a log-concave P (in ℓ 1 distance) and α-close to P (in Kolmogorov distance); and (b) D is 24ε-far from log-concave, assuming we know the mode of the closest log-concave distribution, which has support [n].
In this stage, we compute a partition J of [n] intoÕ 1/ε 2 intervals (here, we implicitly use the knowledge of the mode of the closest log-concave distribution, in order to apply Theorem C.6 differently on two intervals of the support, corresponding to the non-decreasing and non-increasing parts of the target log-concave distribution).
As D is unimodal, we can efficiently (O(log k)) find the interval S of heavy points, that is Each point in S will form a singleton interval in our partition. Let T def = [n] \ S be its complement (T is the union of at most two intervals T 1 , T 2 on which D is monotone, the head and tail of the distribution). For convenience, we focus on only one of these two intervals, without loss of generality the "head" T 1 (on which D is non-decreasing).

C.3.3 Step 3
We start by computing the partition J = (J 1 , . . . , J ℓ ) as in Section C.3.2; with ℓ =Õ 1/ε 2 ; and write J j = {a j , . . . , b j } for all j ∈ [ℓ]. We further denote by S and T the set of heavy and light points, following the notations from Section C.3.2; and let T ′ def = T 1 ∪ T 2 be the set obtained by removing the two "end intervals" (called J in the previous section) from T . Proof. A feasible solution to this linear program will define (setting p i = e x i ) a sequence p = (p 1 , . . . , p n ) ∈ (0, 1] n such that Letting ε i def = |P (i) − D(i)| for i ∈ S, we also immediately have (26) and (27) (since P − D 1 ≤ ε and D − P Kol ≤ α by assumption). Finally, to see why (25) is satisfied, we rewrite and use the fact that ln(1 + x) ≤ x and ln(1 − x) ≥ −2x (the latter for x < 1 2 , along with ε i D(i) ≤ 2α β ≪ 1).
• Follow Section C.3.1 to reduce it to the case where D is unimodal and satisfies the conditions for Kolmogorov and ℓ 1 distance; and a good [a, b] approximation of the support is known The correctness comes from Lemma C.7 and Lemma C.8 and the discussions in Section C.3.1 to Section C.3.3; as for the claimed running time, it is immediate from the algorithm and the fact that the linear program executed each step has poly(n, 1/ε) constraints and variables.

D Proof of Theorem 6.3
In this section, we establish our lower bound for tolerant testing of the Binomial distribution, restated below: Theorem 6.3. There exists an absolute constant ε 0 > 0 such that the following holds. Any algorithm which, given sampling access to an unknown distribution D on Ω and parameter ε ∈ (0, ε 0 ), distinguishes with probability at least 2/3 between (i) D − Bin(n, 1/2) 1 ≤ ε and (ii) D − Bin(n, 1/2) 1 ≥ 100ε must use Ω 1 ε √ n log n samples. The theorem will be a consequence of the (slightly) more general result below: Theorem D.1. There exist absolute constants ε 0 > 0 and λ > 0 such that the following holds. Any algorithm which, given SAMP access to an unknown distribution D on Ω and parameter ε ∈ (0, ε 0 ), distinguishes with probability at least 2/3 between (i) D − Bin n, 1 2 1 ≤ ε and (ii) D − Bin n, 1 2 1 ≥ λε 1/3 − ε must use Ω ε √ n log(ε 2/3 n) samples. By choosing a suitable φ and working out the corresponding parameters, this for instance enables us to derive the following: Corollary D.2. There exists an absolute constant ε 0 ∈ (0, 1/1000) such that the following holds. Any algorithm which, given SAMP access to an unknown distribution D on Ω, distinguishes with probability at least 2/3 between (i) D − Bin n, By standard techniques, this will in turn imply Theorem 6.3.
Proof of Theorem D.1. Hereafter, we write for convenience B n def = Bin n, 1 2 . To prove this lower bound, we will rely on the following: Theorem D.3 ([VV10, Theorem 1]). For any constant φ ∈ (0, 1/4), following holds. Any algorithm which, given SAMP access to an unknown distribution D on Ω, distinguishes with probability at least 2/3 between (i) D − U n 1 ≤ φ and (ii) D − U n 1 ≥ 1 2 − φ, must have sample complexity at least φ 32 n log n . Without loss of generality, assume n is even (so that B n has only one mode located at n 2 ). For c > 0, we write I n,c for the interval { n 2 − c √ n, . . . , n 2 + c √ n} and J n,c def = Ω \ I n,c . The reduction proceeds as follows: given sampling access to D on [n], we can simulate sampling access to a distribution D ′ on [N ] (where N = Θ n 2 ) such that = Θ(φ 3/2 ) and ε ′ def = Θ(φ 1 2 ); in a way that preserves the sample complexity.
More precisely, define c def = 2 ln 1 1−φ = Θ √ φ (so that φ = 1 − e −2c 2 ) and N such that |I N,c | = n (that is, N = (n/(2c)) 2 = Θ n 2 /φ ). From now on, we can therefore identify [n] to I N,c in the obvious way, and see a draw from D as an element in I N,c . • with probability p, we draw a sample from D (seen as an element of I N,c ; • with probability 1 − p, we draw a sample fromB N,c .
LetB N be defined as the distribution which exactly matches B N on J n,c , but is uniform on I n,c : From the above, we have that D ′ −B N 1 = p · D − U n 1 . Furthermore, by Fact D.4, Lemma 2.8 and the definition of I n,c , we get that B N −B N 1 = p · (B N ) In,c − U In,c 1 ≤ p · φ. Putting it all together, • If D − U n 1 ≤ φ, then by the triangle inequality D ′ − B N 1 ≤ p(φ + φ) = 2pφ; Recalling that p = Θ √ φ and setting ε def = 2pφ concludes the reduction. From Theorem D.3, we conclude that φ 32 n log n = Ω φ √ φN log(φN ) = Ω ε √ N log(ε 2/3 N ) samples are necessary.