Documentation

CslibFrontier.Computability.PropertyTesting.Distribution.UniformityCollision

The collision tester for uniformity #

The collision tester of Goldreich–Ron draws k samples from an unknown distribution p on a finite type of size n and accepts when the number of colliding pairs (Cslib.Probability.PMF.collisionCount) is at most C(k, 2) (1 + 2 ε²) / n (collisionThreshold). It is a uniformity tester with proximity ε in statistical distance whenever 40 √n ≤ (k - 1) ε² (isTester_collisionTester), so k = O(√n / ε²) samples suffice; this is Diakonikolas–Gouleakis–Peebles–Price, Theorem 1 (numbering of arXiv:1611.03579v1; stated there in ℓ₂ distance and transferred to total variation by Cauchy–Schwarz) with our own constant. For ε ≤ 1 / 2 on domains of even size this sample complexity is optimal up to the constant, by Paninski's lower bound (Cslib.DistributionTesting.card_le_of_isTester_uniform).

The proof is Chebyshev's inequality with the exact mean and variance of the collision count (Cslib.Probability.PMF.sum_iid_mul_collisionCount_sub_sq), following the variance analysis of Diakonikolas–Gouleakis–Peebles–Price, Lemma 3. Write s = ‖p‖₂² and D = s - 1 / n. If p is uniform, D = 0 and the variance is at most C(k, 2) / n. If p is ε-far from uniform, Cauchy–Schwarz gives n D ≥ 4 ε² (Cslib.Probability.PMF.dist_uniform_sq_le), and the excess third moment is at most D / n + √D D. The original analysis Goldreich–Ron needed O(√n / ε⁴) samples. The constant 40 is the one this proof gives; it is not optimized.

Main definitions #

Main results #

References #

noncomputable def Cslib.DistributionTesting.collisionThreshold (n k : ℕ) (ε : ℝ) :

The collision tester's threshold C(k, 2) (1 + 2 ε²) / n, halfway between the expected collision count C(k, 2) / n of the uniform distribution and C(k, 2) (1 + 4 ε²) / n, a lower bound on the expected collision count of every distribution ε-far from it.

theorem Cslib.DistributionTesting.collisionThreshold_eq (n k : ℕ) (ε : ℝ) :
collisionThreshold n k ε = ↑(k.choose 2) * (1 + 2 * ε ^ 2) / ↑n

Unfolding lemma for collisionThreshold.

noncomputable def Cslib.DistributionTesting.collisionTester {α : Type u_1} [Fintype α] [DecidableEq α] (k : ℕ) (ε : ℝ) :
(Fin k → α) → PMF Bool

The collision tester accepts k samples when their number of colliding pairs is at most collisionThreshold.

theorem Cslib.DistributionTesting.isTester_collisionTester {α : Type u_1} [Fintype α] [DecidableEq α] [Nonempty α] {k : ℕ} {ε : ℝ} (hε : 0 < ε) (hk : 40 * √↑(Fintype.card α) ≤ (↑k - 1) * ε ^ 2) :

The collision tester is a uniformity tester with k = O(√n / ε²) samples.