<p><strong>Edit</strong> I misinterpreted the problem! See Clement's answer instead.</p>

<p>I don't know the context of this paper (not having read it), so I'm not going to address the paper at all, but I can talk about sampling from classical probability distributions which seems to be the question.</p>

<p>In that context, the statement you give is only true fixing the support size of the distribution. The more precise statement was shown in [1], see also [2]. The right bound is $O\left(\max\left\{\frac{n^{2/3}}{\epsilon^{4/3}}, \frac{n^{1/2}}{\epsilon^2}\right\}\right)$ samples suffice when support size is $n$. If you fix $n$, then this is $O(1/\epsilon^2)$ as $\epsilon \to 0$ (as the second term in the max is larger). I think for a proof you have to see those papers, maybe my comments below are also helpful.</p>

<p>If the question is just to tell whether a distribution is uniform or far from uniform, which sounds relevant for the paper you mentioned, then the complexity of this is simply $O\left(\frac{n^{1/2}}{\epsilon^2}\right)$ whose upper bound goes back I'm not sure how far -- it is the idea of birthday paradox -- and whose lower bound was shown by [3].</p>

<p>To show the $\sqrt{n}/\epsilon^2$ upper bound (which is $O(1/\epsilon^2)$ if support size is fixed) is pretty easy: Draw $O(\sqrt{n}/\epsilon^2)$ samples and check the number of collisions. It will be much higher than expected if the distribution is nonuniform. I think you can find something like this in these lecture notes[4], which also mentions the distinguishing-two-distributions problem where similar ideas can be used. (I also have the uniformity-testing case written up in a paper I could reference if wanted.)</p>

<p>To get an idea of a counterexample when support size is not fixed, suppose $\epsilon &lt; 0.5$ and imagine a distribution on support size $n$ where each probability $p_i = \frac{1}{n}\left(1 \pm 2\epsilon\right)$, where say a random half of the coordinates get probability $\frac{1}{n}\left(1 + 2\epsilon\right)$ and the other half get the lower probability. The total variation distance between such a distribution and the uniform distribution is $\epsilon$. But imagine trying to tell whether you have this or the uniform distribution. You can learn nothing if every sample you draw is unique -- you need a "birthday collision". But the chance of a birthday collision gets smaller and smaller as $n$ grows. This construction was used by Paninski to prove the lower bound in [3].</p>

<p>[1] "Optimal Algorithms for Testing Closeness of Discrete Distributions" by Chan, Diakonikolas, G. Valiant, and P. Valiant, 2013. <a href="https://arxiv.org/abs/1308.3946" rel="nofollow noreferrer">https://arxiv.org/abs/1308.3946</a></p>

<p>[2] "A New Approach for Testing Properties of Discrete Distributions" by Diakonikolas and Kane, 2016. <a href="https://arxiv.org/abs/1601.05557" rel="nofollow noreferrer">https://arxiv.org/abs/1601.05557</a></p>

<p>[3] "A Coincidence-Based Test for Uniformity Given Very
Sparsely Sampled Discrete Data", Paninski, 2008. <a href="http://neurotheory.columbia.edu/pdfs/Paninski_2008.pdf" rel="nofollow noreferrer">http://neurotheory.columbia.edu/pdfs/Paninski_2008.pdf</a></p>

<p>[4] <a href="http://www.wisdom.weizmann.ac.il/~oded/PDF/pt-dist.pdf" rel="nofollow noreferrer">http://www.wisdom.weizmann.ac.il/~oded/PDF/pt-dist.pdf</a></p>

CC BY-SA 3.0
2017-02-23T19:46:53.153Z
2017-02-24T01:05:00.120Z
2017-02-24T01:05:00.120Z
usul
<p>So here, you only have two options: either your samples come from $p$, or from $q$ (and you know explicitly both).</p>

<p>By definition of the statistical/total variation distance, we have
$$
d_{TV}(p,q) = \sup_S( p(S)-q(S))
$$
where the supremum is taken over all measurable sets $S$. I haven't looked at the paper, but assuming all is nice (finite), the $\sup$ is a $\max$ and achieved for some particular set $S^\ast$, that you can compute given $p,q$.</p>

<p>So at this point, you have an explicit set $S^\ast$, the values $p(S^\ast)$, $q(S^\ast)$ which by definition satisfy
$$
p(S^\ast) = q(S^\ast) + \varepsilon
$$
and you know that the unknown distribution $h$ is either $p$ or $q$. So to distinguish between the two cases, it suffices to estimate $h(S^\ast)$ up to an additive $\frac{\varepsilon}{2}$, which can be done straightforwardly with $O(1/\varepsilon^2)$ samples.</p>

<hr>

<p><strong>Side remark:</strong> this can be improved a little if both $p(S^\ast), q(S^\ast)$ are both $O(\varepsilon)$ themselves. In which case, distinguishing between the two cases only requires $O(1/\varepsilon)$ samples. (The "hard case" basically is to distinguish $1/2$ from $1/2+\varepsilon$, which requires $\Omega(1/\varepsilon^2)$ samples.)</p>

<hr>

<p><strong>Second remark:</strong> <a href="https://cstheory.stackexchange.com/users/8243/usul">usul</a> refers,in his <a href="https://cstheory.stackexchange.com/a/37612/13319">answer</a>, to a harder problem, composite hypothesis testing. In this problem, you only have <em>one</em> distribution $p$, and want to distinguish between (i) $h=p$ and (ii) $d_{TV}(h,p)&gt;\varepsilon$ (that is, the second option is not a singleton $\{q\}$, but the <em>much</em> larger set of all distributions that are $\varepsilon$-far from $p$). In this case, you need a lot more samples: as a function of the (explicitly known) $p$, this will be basically* $\lVert p^{-\max}_{-\Theta(\varepsilon)}\rVert _{2/3}/\varepsilon^2$ (see [VV14]), where $\lVert p^{-\max}_{-\Theta(\varepsilon)}\rVert _{2/3}$ is a functional of the distribution $p$ (equal to $\Theta(\sqrt{n})$, for instance, when $p$ is the uniform distribution on a set of $n$ elements). See also [BCG16] for an alternative, also tight* characterization of this quantity in terms of another functional.</p>

<p>$*$ The two characterizations are tight in most cases, except some pathological/strange ones.</p>

<hr>

<p>[VV14]  G. Valiant and P. Valiant. <em>An automatic inequality prover and instance optimal identity testing.</em> In Proceedings of FOCS, 2014. <a href="http://theory.stanford.edu/~valiant/papers/instanceOptFull.pdf" rel="nofollow noreferrer">[full version]</a></p>

<p>[BCG16] E. Blais, C. Canonne, and T. Gur. <em>Alice and Bob Show Distribution Testing Lower Bounds (They don't talk to each other anymore.)</em>
Manuscript, 2016. <a href="https://eccc.weizmann.ac.il/report/2016/168/" rel="nofollow noreferrer">[ECCC TR16-168]</a></p>

CC BY-SA 3.0
2017-11-24T20:23:37.783Z
Incidentally, here is a writeup (nothing fancy, basically just the argument above) on it: https://github.com/ccanonne/probabilitydistributiontoolbox/blob/master/testing.pdf
Clement C.
CC BY-SA 3.0
2017-02-23T20:53:21.697Z
2017-02-23T22:22:25.630Z
2017-04-13T12:32:28.077Z
Clement C.
<p>I am looking for a reference (and/or a full proof) for this statement:</p>

<blockquote>
  <p>$O(1/\epsilon^2)$ samples suffice to distinguish any two probability
  distributions with variation distance $\epsilon$.</p>
</blockquote>

<p>I would be very grateful for any pointers.</p>

<reference-request><pr.probability>
Reference for the number of samples needed to distinguish two probability distributions
Simd
# Reference for the number of samples needed to distinguish two probability distributions

(Asked by: username_0 on 2017-02-23)

I am looking for a reference (and/or a full proof) for this statement:

> $O(1/\epsilon^2)$ samples suffice to distinguish any two probability
> distributions with variation distance $\epsilon$.

I would be very grateful for any pointers.

**Tags:** reference-request, pr.probability

---

## 2 answers

### Answer by username_2 on 2017-02-23. Score: 7 | Accepted answer

So here, you only have two options: either your samples come from $p$, or from $q$ (and you know explicitly both).

By definition of the statistical/total variation distance, we have
$$
d\_{TV}(p,q) = \sup\_S( p(S)-q(S))
$$
where the supremum is taken over all measurable sets $S$. I haven't looked at the paper, but assuming all is nice (finite), the $\sup$ is a $\max$ and achieved for some particular set $S^\ast$, that you can compute given $p,q$.

So at this point, you have an explicit set $S^\ast$, the values $p(S^\ast)$, $q(S^\ast)$ which by definition satisfy
$$
p(S^\ast) = q(S^\ast) + \varepsilon
$$
and you know that the unknown distribution $h$ is either $p$ or $q$. So to distinguish between the two cases, it suffices to estimate $h(S^\ast)$ up to an additive $\frac{\varepsilon}{2}$, which can be done straightforwardly with $O(1/\varepsilon^2)$ samples.

---

**Side remark:** this can be improved a little if both $p(S^\ast), q(S^\ast)$ are both $O(\varepsilon)$ themselves. In which case, distinguishing between the two cases only requires $O(1/\varepsilon)$ samples. (The "hard case" basically is to distinguish $1/2$ from $1/2+\varepsilon$, which requires $\Omega(1/\varepsilon^2)$ samples.)

---

**Second remark:** [usul](https://cstheory.stackexchange.com/users/8243/usul) refers,in his [answer](https://cstheory.stackexchange.com/a/37612/13319), to a harder problem, composite hypothesis testing. In this problem, you only have *one* distribution $p$, and want to distinguish between (i) $h=p$ and (ii) $d\_{TV}(h,p)>\varepsilon$ (that is, the second option is not a singleton $\{q\}$, but the *much* larger set of all distributions that are $\varepsilon$-far from $p$). In this case, you need a lot more samples: as a function of the (explicitly known) $p$, this will be basically\* $\lVert p^{-\max}\_{-\Theta(\varepsilon)}\rVert \_{2/3}/\varepsilon^2$ (see [VV14]), where $\lVert p^{-\max}\_{-\Theta(\varepsilon)}\rVert \_{2/3}$ is a functional of the distribution $p$ (equal to $\Theta(\sqrt{n})$, for instance, when $p$ is the uniform distribution on a set of $n$ elements). See also [BCG16] for an alternative, also tight\* characterization of this quantity in terms of another functional.

$\*$ The two characterizations are tight in most cases, except some pathological/strange ones.

---

[VV14] G. Valiant and P. Valiant. *An automatic inequality prover and instance optimal identity testing.* In Proceedings of FOCS, 2014. [[full version]](http://theory.stanford.edu/~valiant/papers/instanceOptFull.pdf)

[BCG16] E. Blais, C. Canonne, and T. Gur. *Alice and Bob Show Distribution Testing Lower Bounds (They don't talk to each other anymore.)*
Manuscript, 2016. [[ECCC TR16-168]](https://eccc.weizmann.ac.il/report/2016/168/)

> **Comments:**
> **username_2**: Incidentally, here is a writeup (nothing fancy, basically just the argument above) on it: https://github.com/ccanonne/probabilitydistributiontoolbox/blob/master/testing.pdf  

---

### Answer by username_1 on 2017-02-23. Score: 1

**Edit** I misinterpreted the problem! See Clement's answer instead.

I don't know the context of this paper (not having read it), so I'm not going to address the paper at all, but I can talk about sampling from classical probability distributions which seems to be the question.

In that context, the statement you give is only true fixing the support size of the distribution. The more precise statement was shown in [1], see also [2]. The right bound is $O\left(\max\left\{\frac{n^{2/3}}{\epsilon^{4/3}}, \frac{n^{1/2}}{\epsilon^2}\right\}\right)$ samples suffice when support size is $n$. If you fix $n$, then this is $O(1/\epsilon^2)$ as $\epsilon \to 0$ (as the second term in the max is larger). I think for a proof you have to see those papers, maybe my comments below are also helpful.

If the question is just to tell whether a distribution is uniform or far from uniform, which sounds relevant for the paper you mentioned, then the complexity of this is simply $O\left(\frac{n^{1/2}}{\epsilon^2}\right)$ whose upper bound goes back I'm not sure how far -- it is the idea of birthday paradox -- and whose lower bound was shown by [3].

To show the $\sqrt{n}/\epsilon^2$ upper bound (which is $O(1/\epsilon^2)$ if support size is fixed) is pretty easy: Draw $O(\sqrt{n}/\epsilon^2)$ samples and check the number of collisions. It will be much higher than expected if the distribution is nonuniform. I think you can find something like this in these lecture notes[4], which also mentions the distinguishing-two-distributions problem where similar ideas can be used. (I also have the uniformity-testing case written up in a paper I could reference if wanted.)

To get an idea of a counterexample when support size is not fixed, suppose $\epsilon < 0.5$ and imagine a distribution on support size $n$ where each probability $p\_i = \frac{1}{n}\left(1 \pm 2\epsilon\right)$, where say a random half of the coordinates get probability $\frac{1}{n}\left(1 + 2\epsilon\right)$ and the other half get the lower probability. The total variation distance between such a distribution and the uniform distribution is $\epsilon$. But imagine trying to tell whether you have this or the uniform distribution. You can learn nothing if every sample you draw is unique -- you need a "birthday collision". But the chance of a birthday collision gets smaller and smaller as $n$ grows. This construction was used by Paninski to prove the lower bound in [3].

[1] "Optimal Algorithms for Testing Closeness of Discrete Distributions" by Chan, Diakonikolas, G. Valiant, and P. Valiant, 2013. <https://arxiv.org/abs/1308.3946>

[2] "A New Approach for Testing Properties of Discrete Distributions" by Diakonikolas and Kane, 2016. <https://arxiv.org/abs/1601.05557>

[3] "A Coincidence-Based Test for Uniformity Given Very
Sparsely Sampled Discrete Data", Paninski, 2008. <http://neurotheory.columbia.edu/pdfs/Paninski_2008.pdf>

[4] <http://www.wisdom.weizmann.ac.il/~oded/PDF/pt-dist.pdf>


---

