Optimal Testing for Properties of Distributions

Jayadev Acharya, Constantinos Daskalakis, Gautam Kamath

Introduction

The quintessential scientific question is whether an unknown object has some property, i.e. whether a model from a specific class fits the object’s observed behavior. If the unknown object is a probability distribution, pp, to which we have sample access, we are typically asked to distinguish whether pp belongs to some class C\mathcal{C} or whether it is sufficiently far from it.

This question has received tremendous attention in the field of statistics (see, e.g., [Fis25, LR06]), where test statistics for important properties such as the ones we consider here have been proposed. Nevertheless, the emphasis has been on asymptotic analysis, characterizing the rates of convergence of test statistics under null hypotheses, as the number of samples tends to infinity. In contrast, we wish to study the following problem in the small sample regime:

The problem has been studied intensely in the literature on property testing and sublinear algorithms [Gol98, Fis01, Rub06, Ron08, Can15], where the emphasis has been on characterizing the optimal tradeoff between pp’s support size and the accuracy ε\varepsilon in the number of samples. Several results have been obtained, roughly clustering into three groups, where (i) C\mathcal{C} is the class of monotone distributions over [n][n], or more generally a poset [BKR04, BFRV11]; (ii) C\mathcal{C} is the class of independent, or kk-wise independent distributions over a hypergrid [BFF+01, AAK+07]; and (iii) C\mathcal{C} contains a single-distribution qq, and the problem becomes that of testing whether pp equals qq or is far from it [BFF+01, Pan08, VV14].

With respect to (iii), [VV14] exactly characterizes the number of samples required to test identity to each distribution qq, providing a single tester matching this bound simultaneously for all qq. Nevertheless, this tester and its precursors are not applicable to the composite identity testing problem that we consider. If our class C\mathcal{C} were finite, we could test against each element in the class, albeit this would not necessarily be sample optimal. If our class C\mathcal{C} were a continuum, we would need tolerant identity testers, which tend to be more expensive in terms of sample complexity [VV11], and result in substantially suboptimal testers for the classes we consider. Or we could use approaches related to generalized likelihood ratio test, but their behavior is not well-understood in our regime, and optimizing likelihood over our classes becomes computationally intense.

In this paper, we obtain sample-optimal and computationally efficient testers for Π(C,ε)\Pi(\mathcal{C},\varepsilon) for the most fundamental shape restrictions to a distribution. Our contributions are the following:

A useful building block and interesting byproduct of our analysis is extending Birgé’s oblivious decomposition for single-dimensional monotone distributions [Bir87] to monotone distributions in d≥1d\geq 1, and to the stronger notion of χ2\chi^{2}-distance. See Section C.1.

Moreover, we show that O(log⁡dn)O(\log^{d}n) samples suffice to learn a monotone distribution over [n]d[n]^{d} in χ2\chi^{2}-distance. See Lemma 5 for the precise statement.

For the classes C=LCDn\mathcal{C}=\mathcal{LCD}_{n}, C=MHRn\mathcal{C}=\mathcal{MHR}_{n} and C=Un\mathcal{C}=\mathcal{U}_{n} of log-concave, monotone-hazard-rate and unimodal distributions over [n][n], we require an optimal Θ(nε2)\Theta\left({\sqrt{n}\over\varepsilon^{2}}\right) number of samples. Our testers for LCDn\mathcal{LCD}_{n} and C=MHRn\mathcal{C}=\mathcal{MHR}_{n} are to our knowledge the first for these classes for the low sample regime we are studying—see [HVK05] and its references for statistics literature on the asymptotic regime. Our tester for Un\mathcal{U}_{n} improves the dependence of the sample complexity on ε\varepsilon by at least a factor of 22 in the exponent, and shaves all logarithmic factors in nn, compared to testers based on testing monotonicity.

A useful building block and important byproduct of our analysis are the first computationally efficient algorithms for properly learning log-concave and monotone-hazard-rate distributions, to within ε\varepsilon in total variation distance, from poly(1/ε){\rm poly}(1/\varepsilon) samples, independent of the domain size nn. See Corollaries 5 and 7. Again, these are the first computationally efficient algorithms to our knowledge in the low sample regime. [ADLS15, CDSS14] provide algorithms for density estimation, which are non-proper, i.e. will approximate an unknown distribution from these classes with a distribution that does not belong to these classes. On the other hand, the statistics literature focuses on maximum-likelihood estimation in the asymptotic regime—see e.g. [CS10] and its references.

For all the above classes we obtain matching lower bounds, showing that the sample complexity of our testers is optimal with respect to nn, ε\varepsilon and when applicable dd. See Section 10. Our lower bounds are based on extending Paninski’s lower bound for testing uniformity [Pan08].

pp and qq are O(ε2)O(\varepsilon^{2})-close in χ2\chi^{2} distance; this case corresponds to p∈Cp\in\mathcal{C}.

We draw a comparison with robust identity testing, in which one must distinguish whether pp and qq are c1εc_{1}\varepsilon-close or c2εc_{2}\varepsilon-far in total variation distance, for constants c2>c1>0c_{2}>c_{1}>0. In [VV11], Valiant and Valiant show that Ω(n/log⁡n)\Omega(n/\log n) samples are required for this problem – a nearly-linear sample complexity, which may be prohibitively large in many settings. In comparison, the problem we study tests for χ2\chi^{2} closeness rather than total variation closeness: a relaxation of the previous problem. However, our tester demonstrates that this relaxation allows us to achieve a substantially sublinear complexity of O(n/ε2)O(\sqrt{n}/\varepsilon^{2}). On the other hand, this relaxation is still tight enough to be useful, demonstrated by our application in obtaining sample-optimal testers.

We note that while the χ2\chi^{2} statistic for testing hypothesis is prevalent in statistics providing optimal error exponents in the large-sample regime, to the best of our knowledge, in the small-sample regime, modified-versions of the χ2\chi^{2} statistic have only been recently used for closeness-testing in [ADJ+12, CDVV14] and for testing uniformity of monotone distributions in [AJOT13]. In particular, [ADJ+12] design an unbiased statistic for estimating the χ2\chi^{2} distance between two unknown distributions.

In Section 4, we show that a version of the χ2\chi^{2} statistic, appropriately excluding certain elements of the support, is sufficiently well-concentrated to distinguish between the above cases. Moreover, the sample complexity of our algorithm is optimal for most classes. Our base tester is combined with the afore-mentioned extension of Birgé’s decomposition theorem to test monotone distributions in Section 5 (see Theorem 3 and Corollary 1), and is also used to test independence of distributions in Section 7 (see Theorem 6).

Naturally, there are several bells and whistles that we need to add to the above skeleton to accommodate all classes of distributions that we are considering. For log-concave and monotone-hazard distributions, we are unable to obtain a cheap (in terms of samples) learner that χ2\chi^{2}-approximates the unknown distribution pp throughout its support. Still, we can identify a subset of the support where the χ2\chi^{2}-approximation is tight and which captures almost all the probability mass of pp. We extend our tester to accommodate excluding subsets of the support from the χ2\chi^{2}-approximation. See Theorems 7 and 8 in Sections 8 and 9.

For unimodal distributions, we are even unable to identify a large enough subset of the support where the χ2\chi^{2} approximation is guaranteed to be tight. But we can show that there exists a light enough piece of the support (in terms of probability mass under pp) that we can exclude to make the χ2\chi^{2} approximation tight. Given that we only use Chebyshev’s inequality to prove the concentration of the test statistic, it would seem that our lack of knowledge of the piece to exclude would involve a union bound and a corresponding increase in the required number of samples. We avoid this through a careful application of Kolmogorov’s max inequality in our setting. See Theorem 5 of Section 6.

Related Work.

For the problems that we study in thie paper, we have provided the related works in the previous section along with our contributions. We cannot do justice to the role of shape restrictions of probability distributions in probabilistic modeling and testing. It suffices to say that the classes of distributions that we study are fundamental, motivating extensive literature on their learning and testing [BBBB72]. In the recent times, there has been work on shape restricted statistics, pioneered by Jon Wellner, and others. [JW09, BW10] study estimation of monotone and k−k- monotone densities, and [BJR11, SW14] study estimation of log-concave distributions.

As we have mentioned, statistics has focused on the asymptotic regime as the number of samples tends to infinity. Instead we are considering the low sample regime and are more stringent about the behavior of our testers, requiring 22-sided guarantees. We want to accept if the unknown distribution is in our class of interest, and also reject if it is far from the class. For this problem, as discussed above, there are few results when C\mathcal{C} is a whole class of distributions. Closer related to our paper is the line of papers [BKR04, ACS10, BFRV11] for monotonicity testing, albeit these papers have sub-optimal sample complexity as discussed above. Testing independence of random variables has a long history in statisics [RS81, AK11]. The theoretical computer science community has also considered the problem of testing independence of two random variables [BFF+01, LRR13]. While our results sharpen the case where the variables are over domains of equal size, they demonstrate an interesting asymmetric upper bound when this is not the case. More recently, Acharya and Daskalakis provide optimal testers for the family of Poisson Binomial Distributions [AD15].

Finally, contemporaneous work of Canonne et al [CDGR15a, CDGR15b] provides a generic algorithm and lower bounds for the single-dimensional families of distributions considered here. We note that their algorithm has a sample complexity which is suboptimal in both nn and ε\varepsilon, while our algorithms are optimal. Their algorithm also extends to mixtures of these classes, though some of these extensions are not computationally efficient. They also provide a framework for proving lower bounds, giving the optimal bounds for many classes when ε\varepsilon is sufficiently large with respect to 1/n1/n. In comparison, we provide these lower bounds unconditionally by modifying Paninski’s construction [Pan08] to suit the classes we consider.

Preliminaries

We use the following probability distances in our paper.

The total variation distance between distributions pp and qq is defined as

The χ2\chi^{2}-distance between pp and qq over [n][n] is defined by

The Kolmogorov distance between two probability measures pp and qq over an ordered set (e.g.e.g., R{\bf R}) with cumulative density functions (CDF) FpF_{p} and FqF_{q} is defined as

Our paper is primarily concerned with testing against classes of distributions, defined formally as follows:

Given ε∈(0,1]\varepsilon\in(0,1] and sample access to a distribution pp, an algorithm is said to test a class C\mathcal{C} if it has the following guarantees:

If p∈Cp\in\mathcal{C}, the algorithm outputs Accept with probability at least 2/32/3;

The Dvoretzky-Kiefer-Wolfowitz (DKW) inequality gives a generic algorithm for learning any distribution with respect to the Kolmogorov distance [DKW56].

We note the following useful relationships between these distances [GS02]:

In this paper, we will consider the following classes of distributions:

Monotone distributions over [n]d[n]^{d} (denoted by Mnd\mathcal{M}_{n}^{d}), for which i≲ji\lesssim j implies fi≥fjf_{i}\geq f_{j}This definition describes monotone non-increasing distributions. By symmetry, identical results hold for monotone non-decreasing distributions.;

Unimodal distributions over [n][n] (denoted by Un\mathcal{U}_{n}), for which there exists an i∗i^{*} such that fif_{i} is non-decreasing for i≤i∗i\leq i^{*} and non-increasing for i≥i∗i\geq i^{*};

Log-concave distributions over [n][n] (denoted by LCDn\mathcal{LCD}_{n}), the sub-class of unimodal distributions for which fi−1fi+1≤fi2f_{i-1}f_{i+1}\leq f_{i}^{2};

Monotone hazard rate (MHR) distributions over [n][n] (denoted by MHRn\mathcal{MHR}_{n}), for which i<ji<j implies fi1−Fi≤fj1−Fj\frac{f_{i}}{1-F_{i}}\leq\frac{f_{j}}{1-F_{j}}.

An η\eta-effective support of a distribution pp is any set SS such that p(S)≥1−ηp(S)\geq 1-\eta.

The flattening of a function ff over a subset SS is the function fˉ\bar{f} such that fˉi=p(S)/∣S∣\bar{f}_{i}=p(S)/|S|.

Let pp be a distribution, and support I1,…I_{1},\ldots is a partition of the domain. The flattening of pp with respect to I1,…I_{1},\ldots is the distribution pˉ\bar{p} which is the flattening of pp over the intervals I1,…I_{1},\ldots.

Throughout this paper, we use the standard Poissonization approach. Instead of drawing exactly mm samples from a distribution pp, we first draw m′∼Poisson(m)m^{\prime}\sim\rm Poisson(m), and then draw m′m^{\prime} samples from pp. As a result, the number of times different elements in the support of pp occur in the sample become independent, giving much simpler analyses. In particular, the number of times we will observe domain element ii will be distributed as Poisson(mpi)\rm Poisson(mp_{i}), independently for each ii. Since Poisson(m)\rm Poisson(m) is tightly concentrated around mm, this additional flexibility comes only at a sub-constant cost in the sample complexity with an inversely exponential in mm, additive increase in the error probability.

Overview

Our algorithm for testing a distribution pp can be decomposed into three steps.

Our first step requires a learning algorithm with very specific guarantees. In proper learning, we are given sample access to a distribution p∈Cp\in\mathcal{C}, where C\mathcal{C} is some class of distributions, and we wish to output q∈Cq\in\mathcal{C} such that pp and qq are close in total variation distance. In our setting, given sample access to p∈Cp\in\mathcal{C}, we wish to output qq such that qq is close to C\mathcal{C} in total variation distance, and pp and qq are close in χ2\chi^{2}-distance on an effective supportWe also require the algorithm to output a description of an effective support for which this property holds. This requirement can be slightly relaxed, as we show in our results for testing unimodality. of pp. From an information theoretic standpoint, this problem is harder than proper learning, since χ2\chi^{2}-distance is more restrictive than total variation distance. Nonetheless, this problem can be shown to have comparable sample complexity to proper learning for the structured classes we consider in this paper.

Computation of distance to class.

The next step is to see if the hypothesis qq is close to the class C\mathcal{C} or not. Since we have an explicit description of qq, this step requires no further samples from pp, i.e. it is purely computational. If we find that qq is far from the class C\mathcal{C}, then it must be that p∉Cp\not\in\mathcal{C}, as otherwise the guarantees from the previous step would imply that qq is close to C\mathcal{C}. Thus, if it is not, we can terminate the algorithm at this point.

At this point, the previous two steps guarantee that our distribution qq is such that:

If p∈Cp\in\mathcal{C}, then pp and qq are close in χ2\chi^{2} distance on a (known) effective support of pp;

We can distinguish between these two cases using O(n/ε2)O(\sqrt{n}/\varepsilon^{2}) samples with a simple statistical χ2\chi^{2}-test, that we describe in Section 4.

Using the above three-step approach, our tester, as described in the next section, can directly test monotonicity, log-concavity, and monotone hazard rate. With an extra trick, using Kolmogorov’s max inequality, it can also test unimodality.

For a known distribution qq, there exists an algorithm with sample complexity

χ2(p,q)<ε2/10\chi^{2}(p,q)<\varepsilon^{2}/10 versus

This theorem follows from our main result of this section, stated next, slightly more generally for classes of distributions.

Suppose we are given ε∈(0,1]\varepsilon\in(0,1], a class of probability distributions C\mathcal{C}, sample access to a distribution pp over [n][n], and an explicit description of a distribution qq with the following properties:

If p∈Cp\in\mathcal{C}, then χ2(p,q)≤ε2500\chi^{2}(p,q)\leq\frac{\varepsilon^{2}}{500}.

Then there exists an algorithm with the following guarantees:

If p∈Cp\in\mathcal{C}, the algorithm outputs Accept with probability at least 2/32/3;

The time and sample complexity of this algorithm are O(nε2)O\left(\frac{\sqrt{n}}{\varepsilon^{2}}\right).

As stated in Theorem 2, Property 2 requires that qq is O(ε2)O(\varepsilon^{2})-close in χ2\chi^{2}-distance to pp over its entire domain. For the class of monotone distributions, we are able to efficiently obtain such a qq, which immediately implies sample-optimal learning algorithms for this class. However, for some classes, we cannot learn a qq with such strong guarantees, and we must consider modifications to our base testing algorithm.

For example, for log-concave and monotone hazard rate distributions, we can obtain a distribution qq and a set SS with the following guarantees:

If p∈Cp\in\mathcal{C}, then χ2(pS,qS)≤O(ε2)\chi^{2}(p_{S},q_{S})\leq O(\varepsilon^{2}) and p(S)≥1−O(ε)p(S)\geq 1-O(\varepsilon);

A further modification can handle even weaker learning guarantees. We could handle the previous case because the tester “knows what we don’t know” – it can explicitly ignore the support over which we do not have a χ2\chi^{2}-closeness guarantee. A more difficult case is when there may be a low measure interval hidden in our effective support, over which pp and qq have a large χ2\chi^{2}-distance. While we may have insufficient samples to reliably identify this interval, it may still have a large effect on our statistic. A naive solution would be to consider a tester which tries all possible “guesses” for this “bad” interval, but a union bound would incur an extra logarithmic factor in the sample complexity. We manage to avoid this cost through a careful analysis involving Kolmogorov’s max inequality, maintaining the O(n/ε2)O(\sqrt{n}/\varepsilon^{2}) sample complexity even in this more difficult case.

Being more precise, we can handle cases where we can obtain a distribution qq and a set of intervals S={I1,…,Ib}S=\{I_{1},\dots,I_{b}\} with the following guarantees:

If p∈Cp\in\mathcal{C}, then p(S)≥1−O(ε)p(S)\geq 1-O(\varepsilon), p(Ij)=Θ(p(S)/b)p(I_{j})=\Theta(p(S)/b) for all j∈[b]j\in[b], and there exists a set T⊆[b]T\subseteq[b] such that ∣T∣≥b−t|T|\geq b-t (for t=O(1)t=O(1)) and χ2(pR,qR)≤O(ε2)\chi^{2}(p_{R},q_{R})\leq O(\varepsilon^{2}), where R=∪TIjR=\cup_{T}I_{j};

This allows us to additionally test against the class of unimodal distributions.

Proof of Theorem 2: Theorem 2 is proven by analyzing Algorithm 1. As shown in Section A, ZZ has the following mean and variance:

where by pAp_{\mathcal{A}} and qAq_{\mathcal{A}} we denote respectively the vectors pp and qq restricted to the coordinates in A\mathcal{A}, and we slightly abuse notation when we write χ2(pA,qA)\chi^{2}(p_{\mathcal{A}},q_{\mathcal{A}}), as these do not then correspond to probability distributions.

Assuming Lemmas 2 and 3, Theorem 2 is now a simple application of Chebyshev’s inequality.

Testing Monotonicity

As an application of our testing framework, we will demonstrate how to test for monotonicity. Let d≥1d\geq 1, and i=(i1,…,id),j=(j1,…,jd)∈[n]d{\bf i}=(i_{1},\ldots,i_{d}),{\bf j}=(j_{1},\ldots,j_{d})\in[n]^{d}. We say i≽j{\bf i}\succcurlyeq{\bf j} if il>jli_{l}>j_{l} for l=1,…,dl=1,\ldots,d.

A distribution pp over [n]d[n]^{d} is monotone (decreasing) if for all i≽j{\bf i}\succcurlyeq{\bf j}, pi≤pjp_{{\bf i}}\leq p_{{\bf j}}.

Our main result of this section is as follows:

For any d≥1d\geq 1, there exists an algorithm for testing monotonicity over [n]d[n]^{d} with sample complexity

and time complexity O(nd/2ε2+poly⁡(log⁡n,1/ε)d)O\left(\frac{n^{d/2}}{\varepsilon^{2}}+\operatorname*{poly}(\log n,1/\varepsilon)^{d}\right).

In particular, this implies the following optimal algorithms for monotonicity testing for all d≥1d\geq 1:

Fix any d≥1d\geq 1, and suppose ε>dlog⁡nn1/4\varepsilon>\frac{\sqrt{d\log n}}{n^{1/4}}. Then there exists an algorithm for testing monotonicity over [n]d[n]^{d} with sample complexity O(nd/2/ε2)O\left(n^{d/2}/\varepsilon^{2}\right).

Our analysis starts with a structural lemma about monotone distributions. In [Bir87], Birgé showed that any monotone distribution pp over [n][n] can be obliviously decomposed into O(log⁡(n)/ε)O(\log(n)/\varepsilon) intervals, such that the flattening pˉ\bar{p} (recall Definition 6) of pp over these intervals is ε\varepsilon-close to pp in total variation distance. [AJOS14] extend this result, giving a bound between the χ2\chi^{2}-distance of pp and pˉ\bar{p}. We strengthen these results by extending them to monotone distributions over [n]d[n]^{d}. In particular, we partition the domain [n]d[n]^{d} of pp into O((dlog⁡(n)/ε2)d)O((d\log(n)/\varepsilon^{2})^{d}) rectangles, and compare it with pˉ\bar{p}, the flattening over these rectangles.

Let d≥1d\geq 1. There is an oblivious decomposition of [n]d[n]^{d} into O((dlog⁡(n)/ε2)d)O((d\log(n)/\varepsilon^{2})^{d}) rectangles such that for any monotone distribution pp over [n]d[n]^{d}, its flattening pˉ\bar{p} over these rectangles satisfy χ2(p,pˉ)≤ε2\chi^{2}(p,\bar{p})\leq\varepsilon^{2}.

This effectively reduces the support size to logarithmic in nn. At this point, we can apply the Laplace estimator (along the lines of [KOPS15]) and learn a qq such that if pp was monotone, then qq will be O(ε2)O(\varepsilon^{2})-close in χ2\chi^{2}-distance.

The final step before we apply our χ2\chi^{2}-tester is to compute the distance between qq and Mnd\mathcal{M}_{n}^{d}. This subroutine is similar to the one introduced by [BKR04]. The key idea is to write a linear program, which searches for any distribution ff which is close to qq in total variation distance. We note that the desired properties of ff (i.e., monotonicity, normalization, and ε\varepsilon-closeness to qq) are easy to enforce as linear constraints. If we find that such an ff exists, we will apply our χ2\chi^{2}-test to qq. If not, we output Reject, as this is sufficient evidence to conclude that p∉Mndp\not\in\mathcal{M}_{n}^{d}. Note that the linear program operates over the oblivious decomposition used in our structural result, so the complexity is polynomial in (dlog⁡(n)/ε)d(d\log(n)/\varepsilon)^{d}, rather than the naive ndn^{d}.

At this point, we have precisely the guarantees needed to apply Theorem 2, directly implying Theorem 3. Proof of the lemmas in this section are provided in Section C. We note that the class of monotone distributions is the simplest of the classes we consider. We now consider testing for log-concavity, monotone hazard rate, and unimodality, all of which are much more challenging to test. In particular, these classes require a more sophisticated structural understanding, more complex proper χ2\chi^{2}-learning algorithms, and non-trivial modifications to our χ2\chi^{2}-tester. We have already given some details on the required adaptations to the tester in Remark 1.

Our algorithms for learning these classes use convex programming. One of the main challenges is to enforce log-concavity of the PDF when learning LCDn\mathcal{LCD}_{n} (respectively, of the CDF when learning MHRn\mathcal{MHR}_{n}), while simultaneously enforcing closeness in total variation distance. This involves a careful choice of our variables, and we exploit structural properties of the classes to ensure the soundness of particular Taylor approximations. We encourage the reader to refer to the proofs of Theorems 5, 7,and 8 for more details.

Testing Unimodality

One striking feature of Birgé’s result is that the decomposition of the domain is oblivious to the samples, and therefore to the unknown distribution. However, such an oblivious decomposition will not work for the unimodal distribution, since the mode is unknown. Suppose we know where the mode of the unknown distribution might be, then the problem can be decomposed into monotone functions over two intervals. Therefore, in theory, one can modify the monotonicity testing algorithm by iterating over all the possible nn modes. Indeed, by applying a union bound, it then follows that

(Follows from Monotone) For ε>1/n1/4\varepsilon>1/n^{1/4}, there exists an algorithm for testing unimodality over [n][n] with sample complexity O(nε2log⁡n)O\left(\frac{\sqrt{n}}{\varepsilon^{2}}\log n\right).

However, this is unsatisfactory, since our lower bound (and as we will demonstrate, the true complexity of this problem) is n/ε2\sqrt{n}/\varepsilon^{2}. We overcome the logarithmic barrier introduced by the union bound, by employing a non-oblivious decomposition of the domain, and using Kolmogorov’s max-inequality.

Our main result for testing unimodality is the following theorem, which is proved in Section D.

Suppose ε>n−1/4\varepsilon>n^{-1/4}. Then there exists an algorithm for testing unimodality over [n][n] with sample complexity O(n/ε2)O(\sqrt{n}/\varepsilon^{2}).

Testing Independence of Random Variables

Let p=p1×p2…×pdp=p^{1}\times p^{2}\ldots\times p^{d}, and q=q1×q2…×qdq=q^{1}\times q^{2}\ldots\times q^{d} be two distributions in Πd\Pi_{d}. Then

Along the lines of learning monotone distributions in χ2\chi^{2} distance we obtain the following result, proved in Section E.

samples from a distribution pp in Πd\Pi_{d} and outputs a distribution q∈Πdq\in\Pi_{d} such that with probability at least 5/65/6,

For any d≥1d\geq 1, there exists an algorithm for testing independence of random variables over [n1]×…[nd][n_{1}]\times\ldots[n_{d}] with sample and time complexity

There exists an algorithm for testing if two distributions over [n][n] are independent with sample complexity Θ(n/ε2)\Theta(n/\varepsilon^{2}).

Testing Log-Concavity

In this section we describe our results for testing log-concavity of distributions. Our main result is as follows:

There exists an algorithm for testing log-concavity over [n][n] with sample complexity

and time complexity poly⁡(n,1/ε)\operatorname*{poly}(n,1/\varepsilon).

In particular, this implies the following optimal tester for this class:

Suppose ε>1/n1/5\varepsilon>1/n^{1/5}. Then there exists an algorithm for testing log-concavity over [n][n] with sample complexity O(n/ε2)O\left(\sqrt{n}/\varepsilon^{2}\right).

Our algorithm will fit into the structure of our general framework. We first perform a very particular type of learning algorithm, whose guarantees are summarized in the following lemma:

Given ε>0\varepsilon>0 and sample access to a distribution pp, there exists an algorithm with the following guarantees:

If p∈LCDnp\in\mathcal{LCD}_{n}, the algorithm outputs a distribution q∈LCDnq\in\mathcal{LCD}_{n} and an O(ε)O(\varepsilon)-effective support SS of pp such that χ2(pS,qS)≤ε2500\chi^{2}(p_{S},q_{S})\leq\frac{\varepsilon^{2}}{500} with probability at least 5/65/6;

The sample complexity is O(1/ε5)O(1/\varepsilon^{5}) and the time complexity is poly⁡(n,1/ε)\operatorname*{poly}(n,1/\varepsilon).

Then, given the guarantees of Lemma 8, Theorem 7 follows from Theorem 2To be more precise, we require the modification of Theorem 7 which is described in Section 4, in order to handle the case where the χ2\chi^{2}-distance guarantees only hold for a known effective support.. The details of these results are presented in Section F.

Testing for Monotone Hazard Rate

In this section, we obtain our main result for testing for monotone hazard rate:

There exists an algorithm for testing monotone hazard rate over [n][n] with sample complexity

and time complexity poly⁡(n,1/ε)\operatorname*{poly}(n,1/\varepsilon).

This implies the following optimal tester for the class:

Suppose ε>log⁡(n/ε)/n1/4\varepsilon>\sqrt{\log(n/\varepsilon)}/n^{1/4}. Then there exists an algorithm for testing monotone hazard rate over [n][n] with sample complexity O(n/ε2)O\left(\sqrt{n}/\varepsilon^{2}\right).

We obey the same framework as before, first applying a χ2\chi^{2}-learner with the following guarantees:

Given ε>0\varepsilon>0 and sample access to a distribution pp, there exists an algorithm with the following guarantees:

If p∈MHRnp\in\mathcal{MHR}_{n}, the algorithm outputs a distribution q∈MHRnq\in\mathcal{MHR}_{n} and an O(ε)O(\varepsilon)-effective support SS of pp such that χ2(pS,qS)≤ε2500\chi^{2}(p_{S},q_{S})\leq\frac{\varepsilon^{2}}{500} with probability at least 5/65/6;

The sample complexity is O(log⁡(n/ε)/ε4)O(\log(n/\varepsilon)/\varepsilon^{4}) and the time complexity is poly⁡(n,1/ε)\operatorname*{poly}(n,1/\varepsilon).

As with log-concave distributions, this implies the following proper learning result:

Again, combining the learning guarantees of Lemma 9 with the appropriate variant of Theorem 2, we obtain Theorem 8. The details of the argument and proofs are presented in Section G.

Lower Bounds

We now prove sharp lower bounds for the classes of distributions we consider. We show that the example studied by Paninski [Pan08] to prove lower bounds on testing uniformity can be used to prove lower bounds for the classes we consider. They consider a class Q\mathcal{Q} consisting of 2n/22^{n/2} distributions defined as follows. Without loss of generality assume that nn is even. For each of the 2n/22^{n/2} vectors z0z1…zn/2−1∈{−1,1}n/2z_{0}z_{1}\ldots z_{n/2-1}\in\{-1,1\}^{n/2}, define a distribution q∈Qq\in\mathcal{Q} over [n][n] as follows.

Each distribution in Q\mathcal{Q} has a total variation distance cε/2c\varepsilon/2 from UnU_{n}, the uniform distribution over [n][n]. By choosing cc to be an appropriate constant, Paninski [Pan08] showed that a distribution picked uniformly at random from Q\mathcal{Q} cannot be distinguished from UnU_{n} with fewer than n/ε2\sqrt{n}/\varepsilon^{2} samples with probability at least 2/32/3.

Suppose C\mathcal{C} is a class of distributions such that

The uniform distribution UnU_{n} is in C\mathcal{C},

then testing C\mathcal{C} is not easier than distinguishing UnU_{n} from Q\mathcal{Q}. Invoking [Pan08] immediately implies that testing the class C\mathcal{C} requires Ω(n/ε2)\Omega(\sqrt{n}/\varepsilon^{2}) samples.

The lower bounds for all the one dimensional distributions will follow directly from this construction, and for testing monotonicity in higher dimensions, we extend this construction to d≥1d\geq 1, appropriately. These arguments are proved in Section H, leading to the following lower bounds for testing these classes:

For any d≥1d\geq 1, any algorithm for testing monotonicity over [n]d[n]^{d} requires Ω(nd/2/ε2)\Omega(n^{d/2}/\varepsilon^{2}) samples.

For d≥1d\geq 1, any algorithm for testing independence over [n1]×⋯×[nd][n_{1}]\times\cdots\times[n_{d}] requires Ω((n1⋅n2…⋅nd)1/2ε2)\Omega\left(\frac{(n_{1}\cdot n_{2}\ldots\cdot n_{d})^{1/2}}{\varepsilon^{2}}\right) samples.

Any algorithm for testing unimodality, log-concavity, or monotone hazard rate over [n][n] requires Ω(n/ε2)\Omega(\sqrt{n}/\varepsilon^{2}) samples.

Acknowledgements

The authors thank Clément Canonne and Jerry Li; the former for several useful comments and suggestions on previous drafts of this work, and both for helpful discussions and thoughts regarding independence testing.

References

Appendix A Moments of the Chi-Squared Statistic

We analyze the mean and variance of the statistic

where each XiX_{i} is independently distributed according to \rm Poisson(\text{mp_{i}}).

The third equality is by noting the random variable has expectation λi\lambda_{i} and the fourth equality substitutes the values of centralized moments of the Poisson distribution.

We first prove the key lemmas in the analysis of our χ2\chi^{2}-test.

Proof of Lemma 2: The former case is straightforward from (1) and Property 2 of qq.

Partitioning the support into A\mathcal{A} and Aˉ\bar{\mathcal{A}}, we have

We consider the following cases separately:

p(Aˉ)≤ε/2p(\bar{\mathcal{A}})\leq\varepsilon/2: In this case,

p(Aˉ)>ε/2p(\bar{\mathcal{A}})>\varepsilon/2: In this case, by the reverse triangle inequality,

Proof of Lemma 3: We bound the terms of (2) separately, starting with the first.

The second inequality is the AM-GM inequality, the third inequality uses that qi≥ε50nq_{i}\geq\frac{\varepsilon}{50n} for all i∈Ai\in\mathcal{A}, the last equality uses (1), and the final inequality substitutes a value m≥20000nε2m\geq 20000\frac{\sqrt{n}}{\varepsilon^{2}}.

The second term can be similarly bounded:

We now consider the two cases in the statement of our lemma.

Combining this with our expression for variance we get:

Appendix C Details on Testing Monotonicity

In this section, we prove the lemmas necessary for our monotonicity testing result.

Birgé [Bir87] showed that any monotone distribution is estimated to a total variation ε\varepsilon with a O(log⁡(n)/ε)O(\log(n)/\varepsilon)-piecewise constant distribution. Moreover, the intervals over which the output is constant is independent of the distribution pp. This result, was strengthened to the Kullback-Leibler divergence by [AJOS14] to study the compression of monotone distributions. They upper bound the KL divergence by χ2\chi^{2} distance and then bound the χ2\chi^{2} distance. We extend this result to [n]d[n]^{d}. We divide [n]d[n]^{d} into bdb^{d} rectangles as follows. Let {I1,…,Ib}\{I_{1},\dots,I_{b}\} be a partition of [n][n] into consecutive intervals defined as:

The χ2\chi^{2} distance between pp and pˉ\bar{p} can be bounded as

For j=(j1,…,jd)∈Slarge{\bf j}=(j_{1},\ldots,j_{d})\in\mathcal{S}_{\rm large}, let j∗=(j1∗,…,jb∗){\bf j}^{*}=(j_{1}^{*},\ldots,j_{b}^{*}) be

We bound the expression above as follows.

Recall that γ=2log⁡(n)/b>1/b\gamma=2\log(n)/b>1/b, implies that the expression above is at most (1+2γ)d−1(1+2\gamma)^{d}-1. This implies Lemma 4.

C.2 Monotone Learning

Our algorithm requires a distribution qq satisfying the properties discussed earlier. We learn a monotone distribution from samples as follows.

Before proving this result, we prove a general result for χ2\chi^{2} learning of arbitrary discrete distributions, adapting the result from [KOPS15]. For a distribution pp, and a partition of the domain into bb intervals I1,…,IbI_{1},\ldots,I_{b}, let pˉi=p(Ii)/∣Ii∣\bar{p}_{i}=p(I_{i})/|I_{i}| be the flattening of pp over these intervals. We saw that for monotone distributions there exists a partition of the domain such that pˉ\bar{p} is close to the underlying distribution in χ2\chi^{2} distance.

Suppose we are given mm samples from a distribution pp and a partition I1,…,IbI_{1},\ldots,I_{b}. Let mjm_{j} be the number of samples that fall in IjI_{j}. For i∈Iji\in I_{j}, let

Let Sj=∑i∈Ijpi2S_{j}=\sum_{i\in I_{j}}p_{i}^{2}. The expected χ2\chi^{2} distance between pp and qq can be bounded as follows.

Suppose γ=O(log⁡(n)/b)\gamma=O(\log(n)/b), and b=O(d⋅log⁡(n)/ε2)b=O(d\cdot\log(n)/\varepsilon^{2}). Then, by Lemma 4,

Appendix D Details on testing Unimodality

Recall that to circumvent Birgé’s decomposition, we want to decompose the interval into disjoint intervals such that the probability of each interval is about O(1/b)O(1/b), where bb is a parameter, specified later. In particular we consider a decomposition of [n][n] with the following properties:

There are at most two intervals with p(I)≤1/2bp(I)\leq 1/{2b}.

Every other interval II satisfies p(I)∈[12b,2b]p(I)\in\left[\frac{1}{2b},\frac{2}{b}\right].

Let I1,…,ILI_{1},\ldots,I_{L} denote the partition of [n][n] corresponding to these intervals. Note that L=O(b)L=O(b).

There is an algorithm that takes O(blog⁡b)O(b\log b) samples and outputs I1,…,ILI_{1},\ldots,I_{L} satisfying the properties above.

The first step in our algorithm is to estimate the total probability within each of these intervals. In particular,

There is an algorithm that takes m′=O(blog⁡b/ε2)m^{\prime}=O(b\log b/\varepsilon^{2}) samples from a distribution pp, and with probability at least 9/10 outputs a distribution qˉ\bar{q} that is constant on each ILI_{L}. Moreover, for any jj such that p(Ij)>1/2bp(I_{j})>1/2b, qˉ(Ij)∈(1±ε)p(Ij)\bar{q}(I_{j})\in(1\pm\varepsilon)p(I_{j}).

Consider any interval IjI_{j} with p(Ij)≥1/2bp(I_{j})\geq 1/2b. The number of samples NIjN_{I_{j}} that fall in that interval is distributed Binomial(m′,p(Ij)Binomial(m^{\prime},p(I_{j}). Then by Chernoff bounds for m′>12blog⁡b/ε2m^{\prime}>12b\log b/\varepsilon^{2},

where the last inequality uses the fact that p(Ij)≥1/2bp(I_{j})\geq 1/2b. ∎

The next step is estimate the distance of qq from Un\mathcal{U}_{n}. This is possible by a simple dynamic program, similar to the one used for monotonicity. If the estimated distance is more than ε/2\varepsilon/2, we output Reject.

Our next step is to remove certain intervals. This will be to ensure that when the underlying distribution is unimodal, we are able to estimate the distribution multiplicatively over the remaining intervals. In particular, we do the following preprocessing step:

Add the (at most 2) intervals with mass at most 1/2b1/2b to AA.

Add all intervals jj with q(Ij)/∣Ij∣<ε/50nq(I_{j})/|I_{j}|<\varepsilon/50n to AA

If the distribution is unimodal, we can prove the following about the set of intervals Ac{A^{c}}.

p(IAc)≥1−ε/25−1/b−O(log⁡n/(εb)).p(I_{A^{c}})\geq 1-\varepsilon/25-1/b-O\left(\log n/(\varepsilon b)\right).

Except at most one interval in Ac{A^{c}} every other interval IjI_{j} satisfies,

If this holds, then the χ2\chi^{2} distance between pp and qq constrained to AcA^{c}, is at most ε2\varepsilon^{2}. This lemma follows from the following result.

Let C>2C>2. For a unimodal distribution over [n][n], there are at most 4log⁡(50n/ε)Cε\frac{4\log(50n/\varepsilon)}{C\varepsilon} intervals IjI_{j} that satisfy pj+pj−<(1+ε/C)\frac{p_{j}^{+}}{p_{j}^{-}}<(1+\varepsilon/C).

To the contrary, if there are more than 4log⁡(50n/ε)Cε\frac{4\log(50n/\varepsilon)}{C\varepsilon} intervals, then at least half of them are on one side of the mode, however this implies that the ratio of the largest probability and smallest probability is at least (1+ε/C)j(1+\varepsilon/C)^{j}, and if j>2log⁡(50n/ε)Cεj>\frac{2\log(50n/\varepsilon)}{C\varepsilon}, is at least 50n/ε50n/\varepsilon, contradicting that we have removed all such elements. ∎

We have one additional pre-processing step here. We compute q(Ac)q(A^{c}) and if it is smaller than 1−ε/251-\varepsilon/25, we output Reject.

Suppose there are L′L^{\prime} intervals in AcA^{c}. Then, except at most one interval in L′L^{\prime} we know that the χ2\chi^{2} distance between pp and qq is at most ε2\varepsilon^{2} when pp is unimodal, and the TV distance between pp and qq is at least ε/2\varepsilon/2 over AcA^{c}. We propose the following simple modification to take into account, the one interval that might introduce a high χ2\chi^{2} distance in spite of having a small total variation. If we knew the interval, we can simply remove it and proceed. Since we do not know where the interval lies, we do the following.

Let ZjZ_{j} be the χ2\chi^{2} statistic over the iith interval in AcA^{c}, computed with O(n/ε2)O(\sqrt{n}/\varepsilon^{2}) samples.

Let ZlZ_{l} be the largest among all ZjZ_{j}’s.

If ∑j,j≠lZj>mε2/10\sum_{j,j\neq l}Z_{j}>m\varepsilon^{2}/10, output Reject.

The objective of removing the largest χ2\chi^{2} statistic is our substitute for not knowing the largest interval. We now prove the correctness of this algorithm.

We only concentrate on the final step. The χ2\chi^{2} statistic over all but one interval are at most c⋅mε2c\cdot m\varepsilon^{2}, and the variance is bounded as before. Since we remove the largest statistic, the expected value of the new statistic is strictly dominated by that of these intervals. Therefore, the algorithm outputs Accept with at least the same probability as if we removed the spurious interval.

This is the hard case to prove for unimodal distributions. We know that the χ2\chi^{2} statistic is large in this case, and we therefore have to prove that it remains large even after removing the largest test statistic ZlZ_{l}.

We invoke Kolmogorov’s Maximal Inequality to this end.

In this section we prove Lemma 7. The proof is analogous to the proof for learning monotone distributions, and hinges on the following result of [KOPS15]. Given mm samples from a distribution qq over nn elements, the add-1 estimator (Laplace estimator) qq satisfies:

Now, suppose pp is a product distribution over X=[n1]×⋯×[nd]{\cal X}=[n_{1}]\times\cdots\times[n_{d}]. We simply perform the add-1 estimation over each coordinate independently, giving a distribution q1×⋯×qdq^{1}\times\cdots\times q^{d}. Since pp is a product distribution the estimates in each coordinate is independent. Therefore, a simple application of the previous result and independence of the coordinates implies

where (17) follows from ex≥1+xe^{x}\geq 1+x. Using ex≤1+2xe^{x}\leq 1+2x for 0≤x≤10\leq x\leq 1, we have

when m≥∑lnlm\geq\sum_{l}n_{l}. Therefore, following an application of Markov’s inequality, when m=Ω((∑lnl)/ε2)m=\Omega((\sum_{l}n_{l})/\varepsilon^{2}), Lemma 7 is proved.

Appendix F Details on Testing Log-Concavity

Proof of Lemma 8: We first draw samples from pp and obtain a O(1/ε3/2)O(1/\varepsilon^{3/2})-piecewise constant distribution ff by appropriately flattening the empirical distribution. The proof is now in two parts. In the first part, we show that if p∈LCDnp\in\mathcal{LCD}_{n} then ff will be close to pp in χ2\chi^{2} distance over its effective support. The second part involves proper learning of pp. We will use a linear program on ff to find a distribution q∈LCDnq\in\mathcal{LCD}_{n}. This distribution is such that if p∈LCDnp\in\mathcal{LCD}_{n}, then χ2(p,q)\chi^{2}(p,q) is small, and otherwise the algorithm will either output some q∈LCDnq\in\mathcal{LCD}_{n} (with no other relevant guarantees) or Reject.

Let aa be the minimum ii such that pi≥ε3/2/5p_{i}\geq\varepsilon^{3/2}/5, and let bb be the maximum ii satisfying the same condition. Let M={a,…,b}M=\{a,\dots,b\} or ∅\emptyset if aa and bb are undefined. By the guarantee provided by the DKW inequality, pi≥ε3/2/10p_{i}\geq\varepsilon^{3/2}/10 for all i∈Mi\in M. Furthermore, p^i∈pi±ε3/2/10∈(1±ε)⋅pi\hat{p}_{i}\in p_{i}\pm\varepsilon^{3/2}/10\in(1\pm\varepsilon)\cdot p_{i}. For each i∈Mi\in M, let fi=p^if_{i}=\hat{p}_{i}. We note that ∣M∣=O(1/ε)|M|=O(1/\varepsilon), so this contributes O(1/ε)O(1/\varepsilon) constant pieces to ff.

We now divide the rest of the domain into tt intervals, all but constantly many of measure Θ(ε3/2)\Theta(\varepsilon^{3/2}) (under pp). This is done via the following iterative procedure. As a base case, set r0=0r_{0}=0. Define IjI_{j} as [lj,rj][l_{j},r_{j}], where lj=rj−1+1l_{j}=r_{j-1}+1 and rjr_{j} is the largest j∈[n]j\in[n] such that p^(Ij)≤9ε3/2/10\hat{p}(I_{j})\leq 9\varepsilon^{3/2}/10. The exception is if IjI_{j} would intersect MM – in this case, we “skip” MM: set rj=a−1r_{j}=a-1 and lj+1=b+1l_{j+1}=b+1. If such a jj exists, denote it by j∗j^{*}. We note that p(Ij)≤p^(Ij)+ε5/2/10≤ε3/2p(I_{j})\leq\hat{p}(I_{j})+\varepsilon^{5/2}/10\leq\varepsilon^{3/2}. Furthermore, for all jj except j∗j^{*} and tt, rj+1∉Mr_{j}+1\not\in M, so p(Ij)≥9ε3/2/10−ε3/2/5−ε5/2/10≥3ε3/2/5p(I_{j})\geq 9\varepsilon^{3/2}/10-\varepsilon^{3/2}/5-\varepsilon^{5/2}/10\geq 3\varepsilon^{3/2}/5. Observe that this lower bound implies that t≤2ε3/2t\leq\frac{2}{\varepsilon^{3/2}} for ε\varepsilon sufficiently small.

For this part of the algorithm, we only care about the guarantees when p∈LCDnp\in\mathcal{LCD}_{n}, so we assume this is the case.

For the domain [n]∖M[n]\setminus M, we let ff be the flattening of p^\hat{p} over the intervals I1,…ItI_{1},\dots I_{t}. To analyze ff, we need a structural property of log-concave distributions due to Chan, Diakonikolas, Servedio, and Sun [CDSS13]. This essentially states that a log-concave distribution cannot have a sudden increase in probability.

Let pp be a distribution over [n][n] that is non-decreasing and log-concave on [1,x]⊆[n][1,x]\subseteq[n]. Let I=[x,y]I=[x,y] be an interval of mass P(I)=τP(I)=\tau, and suppose that the interval J=[1,x−1]J=[1,x-1] has mass p(J)=σ>0p(J)=\sigma>0. Then

Recall that any log-concave distribution is unimodal, and suppose the mode of pp is at i0i_{0}. We will first focus on the intervals I1,…,ItLI_{1},\dots,I_{t_{L}} which lie entirely to the left of i0i_{0} and MM. We will refer to IjI_{j} as LjL_{j} for all j≤tLj\leq t_{L}. Note that pp is non-decreasing over these intervals.

The next steps to the analysis are as follows. First we show that the flattening of pp over LjL_{j} is a multiplicative (1+O(1/j))(1+O(1/j)) estimate for each pi∈Ljp_{i}\in L_{j}. Then, we show that flattening the empirical distribution p^\hat{p} over LjL_{j} is a multiplicative (1+O(1/j))(1+O(1/j)) estimate of p(i)p(i) for each i∈Lji\in L_{j}. Finally, we exclude a small number of intervals (those corresponding to O(ε)O(\varepsilon) mass at the left and right side of the domain, as well as j∗j^{*}) in order to get the χ2\chi^{2} approximation we desire on an effective support.

First, recall that p(Lj)≤ε3/2p(L_{j})\leq\varepsilon^{3/2} for all jj. Also, letting Jj=[1,rj−1]J_{j}=[1,r_{j-1}], we have that p(Jj)≥(j−1)⋅3ε3/2/5p(J_{j})\geq(j-1)\cdot 3\varepsilon^{3/2}/5. Thus by Lemma 14, p(rj)≤p(lj)(1+2/(j−1))p(r_{j})\leq p(l_{j})(1+2/(j-1)). Since the distribution is non-decreasing in LjL_{j}, the flattening pˉ\bar{p} of pp is such that pˉ(i)∈p(i)(1±2j−1)\bar{p}(i)\in p(i)(1\pm\frac{2}{j-1}) for all i∈Lji\in L_{j}.

We have that p(Lj)≥3ε3/2/5p(L_{j})\geq 3\varepsilon^{3/2}/5, and p^(Lj)∈p(Lj)±ε5/2/10\hat{p}(L_{j})\in p(L_{j})\pm\varepsilon^{5/2}/10, so p^(Lj)∈p(Lj)⋅(1±ε6)\hat{p}(L_{j})\in p(L_{j})\cdot(1\pm\frac{\varepsilon}{6}), and hence p^(i)∈pˉ(i)⋅(1±ε6)\hat{p}(i)\in\bar{p}(i)\cdot(1\pm\frac{\varepsilon}{6}) for all i∈Lji\in L_{j}. Combining with the previous point, we have that

A symmetric statement holds for the intervals that lie entirely to the right of i0i_{0} and MM. We will refer to IjI_{j} as Rt−jR_{t-j} for all j>tLj>t_{L}.

To summarize, we have the following guarantees for the distribution ff:

For all i∈Mi\in M, f(i)∈p(i)⋅(1±ε)f(i)\in p(i)\cdot(1\pm\varepsilon);

For all i∈Lji\in L_{j} (except L1L_{1} and Lj∗L_{j^{*}}), f(i)∈p(i)⋅(1±223j)f(i)\in p(i)\cdot\left(1\pm\frac{22}{3j}\right);

For all i∈Rji\in R_{j} (except R1R_{1}), f(i)∈p(i)⋅(1±223j)f(i)\in p(i)\cdot\left(1\pm\frac{22}{3j}\right);

Note that, in particular, we have multiplicative estimates for all intervals, except those in L1L_{1}, Lj∗L_{j^{*}}, R1R_{1} and the interval containing i0i_{0}. Let SS be the set of all intervals except Lj∗L_{j^{*}}, LjL_{j} and RjR_{j} for j≤1/εj\leq 1/\sqrt{\varepsilon}, and the one containing i0i_{0} Then, since each interval has probability mass at most O(ε3/2)O(\varepsilon^{3/2}) and we are excluding O(1/ε)O(1/\sqrt{\varepsilon}) intervals, p(S)>1−O(ε)p(S)>1-O(\varepsilon).

We now compute the χ2\chi^{2}-distance induced by this approximation for elements in SS. For an element i∈Lj∩Si\in L_{j}\cap S, we have

Summing over all i∈Lj∩Si\in L_{j}\cap S gives

since the probability mass of LjL_{j} is at most ε3/2\varepsilon^{3/2}. Summing this over all LjL_{j} for j≥1/εj\geq 1/\sqrt{\varepsilon} and j≠j∗j\neq j^{*} gives

Part 2.

To obtain a distribution q∈LCDnq\in\mathcal{LCD}_{n}, we write a linear program. We will work in the log domain, so our variables will be QiQ_{i}, representing log⁡q(i)\log q(i) for i∈[n]i\in[n]. We will use Fi=log⁡f(i)F_{i}=\log f(i) as parameters in our LP. There will be no objective function, we simply search for a feasible point. Our constraints will be

If we run the linear program, then after a rescaling and summing the error over all the intervals in the LP gives us that the distance between pp and qq to be O(ε2)O(\varepsilon^{2}) χ2\chi^{2}-distance in a set SS which has measure p(S)≥1−4εp(S)\geq 1-4\varepsilon, as desired.

If the linear program finds a feasible point, then we obtain a q∈LCDnq\in\mathcal{LCD}_{n}. Furthermore, if p∈LCDnp\in\mathcal{LCD}_{n}, this also tells us that (after a rescaling of ε\varepsilon), summing the error over all intervals implies that χ2(pS,qS)≤ε2500\chi^{2}(p_{S},q_{S})\leq\frac{\varepsilon^{2}}{500} for a known set SS with p(S)≥1−O(ε)p(S)\geq 1-O(\varepsilon), as desired. If M≠∅M\neq\emptyset, this algorithm works as described. The issue is if M=∅M=\emptyset, then we don’t know when the LL intervals end and the RR intervals begin. In this case, we run O(1/ε)O(1/\varepsilon) LPs, using each interval as the one containing i0i_{0}, and thus acting as the barrier between the LL intervals (to its left) and the RR intervals (to its right). If pp truly was log-concave, then one of these guesses will be correct and the corresponding LP will find a feasible point. \hfill\qed\hfill\qed

Appendix G Details on MHR testing

Proof of Lemma 9: As with log-concave distributions, our method for MHR distributions can be split into two parts. In the first step, if p∈MHRnp\in\mathcal{MHR}_{n}, we obtain a distribution qq which is O(ε2)O(\varepsilon^{2})-close to pp in χ2\chi^{2} distance on a set A\mathcal{A} of intervals such that p(A)≥1−O(ε)p(\mathcal{A})\geq 1-O(\varepsilon). qq will achieve this by being a multiplicative (1+O(ε))(1+O(\varepsilon)) approximation for each element within these intervals. This step is very similar to the decomposition used for unimodal distributions (described in Section D), so we sketch the argument and highlight the key differences.

The analysis will rely on the following lemma from [CDSS13], which roughly states that an MHR distribution is “almost” non-decreasing.

Let pp be an MHR distribution over [n][n]. Let I=[a,b]⊂[n]I=[a,b]\subset[n] be an interval, and R=[b+1,n]R=[b+1,n] be the elements to the right of II. Let η=p(I)/p(R)\eta=p(I)/p(R). Then p(b+1)≥11+ηp(a)p(b+1)\geq\frac{1}{1+\eta}p(a).

As before, with unimodal distributions, we start by taking O(blog⁡bε2)O(\frac{b\log b}{\varepsilon^{2}}) samples, with the goal of partitioning the domain into intervals of mass approximately Θ(1/b)\Theta(1/b). First, we will ignore the left and rightmost intervals of mass Θ(ε)\Theta(\varepsilon). For all “heavy” elements with mass ≥Θ(1/b)\geq\Theta(1/b), we consider them as singletons. We note that Lemma 15 implies that there will be at most O(1/ε)O(1/\varepsilon) contiguous intervals of such elements. The rest of the domain is greedily divided (from left to right) into intervals of mass Θ(1/b)\Theta(1/b), cutting an interval short if we reach one of the heavy elements. This will result in the guarantee that all but potentially O(1/ε)O(1/\varepsilon) intervals have Θ(1/b)\Theta(1/b) mass.

Next, similar to unimodal distributions, considering the flattened distribution, we discard all intervals for which the per-element probability is not within a (1±O(ε))(1\pm O(\varepsilon)) multiplicative factor of the same value for both neighboring intervals. The claim is that all remaining intervals will have the property that the per-element probability is within a (1±O(ε))(1\pm O(\varepsilon)) multiplicative factor of the true probability. This is implied by Lemma 15. If there were a point in an interval which was above this range, the distribution must decrease slowly, and the next interval would have a much larger per-element weight, thus leading to the removal of this interval. A similar argument forbids us from missing an interval which contains a point that lies outside this range. Relying on the fact that truncating the left and rightmost intervals eliminates elements with low probability mass, similar to the unimodal case, one can show that we will remove at most log⁡(n/ε)/ε\log(n/\varepsilon)/\varepsilon intervals, and thus a log⁡(n/ε)/bε\log(n/\varepsilon)/b\varepsilon probability mass. Choosing b=Ω(ε2/log⁡(n/ε))b=\Omega(\varepsilon^{2}/\log(n/\varepsilon)) limits this to be O(ε)O(\varepsilon), as desired. At this point, if pp is indeed MHR, the multiplicative estimates guarantee that the result is O(ε2)O(\varepsilon^{2})-close in χ2\chi^{2}-distance among the remaining intervals.

Part 2.

We note that an equivalent condition for distribution ff being MHR is log-concavity of log⁡(1−F)\log(1-F), where FF is the CDF of ff. Therefore, our approach for this part will be similar to the approach used for log-concave distributions.

Given the output distribution qq from the previous part of this algorithm, our goal will be check if there exists an MHR distribution ff which is O(ε)O(\varepsilon)-close to qq. We will run a linear program with variables fi=log⁡(1−Fi)\mathfrak{f}_{i}=\log(1-F_{i}). First, we ensure that ff is a distribution. This can be done with the following constraints:

To ensure that ff is MHR, we use the following constraint:

Now, ideally, we would like to ensure ff and qq are ε\varepsilon-close in total variation distance by ensuring they are pointwise within a multiplicative (1±ε)(1\pm\varepsilon) factor of each other:

We note that this is a stronger condition than ff and qq being ε\varepsilon-close, but if p∈MHRnp\in\mathcal{MHR}_{n}, the guarantees of the previous step would imply the existence of such an ff.

We have a separate treatment for the identified singletons (i.e., those with probability ≥1/b\geq 1/b) and the remainder of the support. For each element qiq_{i} identified to have ≥1/b\geq 1/b mass, we add two constraints:

If we satisfy these constraints, it implies that

Now, the remaining elements each have ≤1/b\leq 1/b mass. For each such element qiq_{i}, we create a constraint

where the second equality uses the Taylor expansion and the facts that fi≤1/bf_{i}\leq 1/b and 1−Fi−1≥ε1-F_{i-1}\geq\varepsilon (since during the previous part, we ignored the rightmost O(ε)O(\varepsilon) probability mass). If we satisfy the desired constraints, it implies that

Since we are taking Ω(1/ε4)\Omega(1/\varepsilon^{4}) samples and 1−Fi−1≥Ω(ε)1-F_{i-1}\geq\Omega(\varepsilon), Lemma 1 implies that fif_{i} is indeed a multiplicative (1±ε)(1\pm\varepsilon) approximation for these points as well.

We note that all points which do not fall into these two cases make up a total of O(ε)O(\varepsilon) probability mass. Therefore, ff may be arbitrary at these points and only incur O(ε)O(\varepsilon) cost in total variation distance.

If we find a feasible point for this linear program, it implies the existence of an MHR distribution within O(ε)O(\varepsilon) total variation distance. In this case, we continue to the testing portion of the algorithm. Furthermore, if p∈MHRnp\in\mathcal{MHR}_{n}, our method for generating qq certifies that such a distribution exists, and we continue on to the testing portion of the algorithm. \hfill\qed\hfill\qed

Appendix H Details of the Lower Bounds

We first consider d=1d=1 and prove that for appropriately chosen cc, any monotone distribution over [n][n] is ε\varepsilon-far from all distributions in Q\mathcal{Q}. Consider any q∈Qq\in\mathcal{Q}. For this distribution, we say that i∈[n]i\in[n] is a raise-point if qi<qi+1q_{i}<q_{i+1}. Let RqR_{q} be the set of raise points of qq. For q∈Qq\in\mathcal{Q}, (6) implies at least one in every four consecutive integers in [n][n] is a raise point, and therefore, ∣Rq∣≥n/4|R_{q}|\geq n/4. Moreover, note that if ii is a raise-point, then i+1i+1 is not a raise point. For any monotone (decreasing) distribution pp, pi≥pi+1p_{i}\geq p_{i+1}. For any raise-point i∈Rqi\in R_{q}, by the triangle inequality,

H.2 Testing Product Distributions

Our idea for testing independence is similar to the previous section. We sketch the construction of a class of distributions on X=[n1]×⋯×[nd]{\cal X}=[n_{1}]\times\cdots\times[n_{d}]. Then ∣X∣=n1⋅n2…⋅nd|{\cal X}|=n_{1}\cdot n_{2}\ldots\cdot n_{d}. For each element in X{\cal X} assign a value (1±cε)(1\pm c\varepsilon) and then for each such assignment, normalize the values so that they add to 1, giving rise to a distribution. This gives us a class of 2∣X∣2^{|{\cal X}|} distributions. The key argument is to show that a large fraction of these distributions are far from being a product distribution. This follows since the degrees of freedom of a product distribution is exponentially smaller than the number of possible distributions. The second step is to simply apply Paninski’s argument, now over the larger set of distributions, where we show that distinguishing the collection of distributions we constructed from the uniform distribution over X{\cal X} (which is a product distribution) requires ∣X∣/ε2\sqrt{|{\cal X}|}/\varepsilon^{2} samples.

H.3 Log-concave and Unimodal distributions

H.4 Monotone Hazard distributions

We will show that any monotone hazard rate distribution is ε\varepsilon-far from all distributions in Q\mathcal{Q}.

Let pp be any monotone-hazard distribution. Any distribution q∈Qq\in\mathcal{Q} has mass at least 1/21/2 over the interval I=[n/4,3n/4]I=[n/4,3n/4]. Therefore, by Lemma 15, for any i∈Ii\in I, pi+1(1+pi1/4)≥pip_{i+1}\left(1+\frac{p_{i}}{1/4}\right)\geq p_{i}. As noted before, at least n/8n/8 of the raise-points are in II.

For any i∈I∩Rqi\in I\cap R_{q}, qi=(1+cε)/nq_{i}=(1+c\varepsilon)/n, qi+1=(1−cε)/nq_{i+1}=(1-c\varepsilon)/n

If pi≥(1+2cε)/np_{i}\geq(1+2c\varepsilon)/n or pi≤1/np_{i}\leq 1/n, then the first term, and therefore did_{i} is at least cε/nc\varepsilon/n. If pi∈(1/n,(1+2cε)/n)p_{i}\in(1/n,(1+2c\varepsilon)/n), then for n>5/(cε)n>5/(c\varepsilon)

Therefore the second term of did_{i} is at cε/2nc\varepsilon/2n. Since there are at least n/8n/8 raise points in II,

Thus any MHR distribution is ε\varepsilon-far from Q\mathcal{Q} for c≥16c\geq 16. ‏