Documentation

CslibFrontier.Computability.PropertyTesting.Distribution.ClosenessFlattening

The closeness tester by flattening #

Testing whether two unknown distributions p, q on n points are equal or at statistical distance at least ε takes Θ(n^{2/3} ε^{-4/3} + √n ε^{-2}) samples [Chan–Diakonikolas–Valiant–Valiant] [CDVV14]. This file proves the upper bound with explicit constants by the flattening reduction of Diakonikolas–Kane, Proposition 2.10 (numbering of arXiv:1601.05557v1): split both distributions along the occurrences of a first batch of samples, which makes both of their collision probabilities small (CslibFrontier.Probability.Split), then run the ℓ₂ closeness tester closenessTester on the split distributions.

closenessFlatteningTester m k ε draws m + k samples x, y of each distribution. The first m samples x₁, y₁ of each fix the counts c a = N_a(x₁) + N_a(y₁) (flatteningCount), so that ∑ c = 2m and the split domain Σ a, Fin (c a + 1) has n + 2m points. The other k samples of each are passed independently through the split kernel and tested by closenessTester k (2 ε / √(n + 2m)) (splitClosenessTester).

Taking m = ⌈t⌉ for t = min(n, n^{2/3} ε^{-4/3}) gives m + k ≤ 520 max(n^{2/3} ε^{-4/3}, √n ε^{-2}) + 3 (exists_isClosenessTester_closenessFlatteningTester).

The tester deviates from Diakonikolas–Kane, Proposition 2.10 in two ways, both to stay within the fixed-sample model of acceptProb₂. It takes a fixed number m of flattening samples instead of a Poisson number. It also flattens with samples of both p and q rather than of q alone, so that both split collision probabilities are small. This replaces Diakonikolas–Kane, Lemma 2.3, which needs only one of the two norms to be small but estimates both norms first. Statistical distance dist is half the ℓ₁ distance, so proximity ε here is ‖p - q‖₁ ≥ 2 ε in the notation of the paper.

Main definitions #

Main results #

References #

def Cslib.DistributionTesting.flatteningCount {α : Type u_1} [DecidableEq α] {m : ℕ} (x y : Fin m → α) (a : α) :

The flattening counts: the number of occurrences of a in the flattening samples x and y together.

theorem Cslib.DistributionTesting.sum_flatteningCount {α : Type u_1} [Fintype α] [DecidableEq α] {m : ℕ} (x y : Fin m → α) :
∑ a : α, flatteningCount x y a = 2 * m

The flattening counts add up to 2 m.

noncomputable def Cslib.DistributionTesting.flatteningProximity (α : Type u_1) [Fintype α] (m : ℕ) (ε : ℝ) :

The ℓ₂ proximity 2 ε / √(n + 2m) on the split domain of n + 2m points.

theorem Cslib.DistributionTesting.flatteningProximity_eq {α : Type u_1} [Fintype α] (m : ℕ) (ε : ℝ) :
flatteningProximity α m ε = 2 * ε / √(↑(Fintype.card α) + 2 * ↑m)

Unfolding lemma for flatteningProximity.

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

The ℓ₂ closeness tester run on the samples passed independently through the split kernel.

The split tester accepts p, q with the probability that the ℓ₂ tester accepts the split distributions.

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

The closeness tester by flattening. Of the m + k samples of each distribution, the first m of both fix the split counts, and the other k of each are split and tested by the ℓ₂ closeness tester with proximity 2 ε / √(n + 2m).

theorem Cslib.DistributionTesting.closenessFlatteningTester_apply {α : Type u_1} [Fintype α] [DecidableEq α] (m k : ℕ) (ε : ℝ) (x y : Fin (m + k) → α) :
closenessFlatteningTester m k ε x y = splitClosenessTester (flatteningCount (fun (j : Fin m) => x (Fin.castAdd k j)) fun (j : Fin m) => y (Fin.castAdd k j)) k (flatteningProximity α m ε) (fun (i : Fin k) => x (Fin.natAdd m i)) fun (i : Fin k) => y (Fin.natAdd m i)

Unfolding lemma for closenessFlatteningTester.

The acceptance probability of the flattening tester averages, over the flattening samples x₁, y₁, the acceptance probability of the ℓ₂ tester on the distributions split along x₁, y₁.

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

The closeness tester by flattening, a fixed-sample, two-sided variant of Diakonikolas–Kane, Proposition 2.10: on a domain of size n, with m flattening samples and k testing samples of each distribution, closenessFlatteningTester m k ε is a closeness tester with proximity ε whenever 0 < ε and 864 (n + 2m) ≤ 5 (k - 1) ε² √(m + 1).

theorem Cslib.DistributionTesting.isClosenessTester_closenessFlatteningTester_ceil {α : Type u_1} [Fintype α] [DecidableEq α] {t ε : ℝ} (ht : 0 < t) (htn : t ≤ ↑(Fintype.card α)) (hε : 0 < ε) :

Choosing the parameters. For any real flattening budget 0 < t ≤ n, the flattening tester with m = ⌈t⌉ and k = ⌈2592 n / (5 ε² √t)⌉ + 1 is a closeness tester with proximity ε.

theorem Cslib.DistributionTesting.exists_isClosenessTester_closenessFlatteningTester {α : Type u_1} [Fintype α] [DecidableEq α] [Nonempty α] {ε : ℝ} (hε : 0 < ε) :
∃ (m : ℕ) (k : ℕ), ↑(m + k) ≤ 520 * max (↑(Fintype.card α) ^ (2 / 3) / ε ^ (4 / 3)) (√↑(Fintype.card α) / ε ^ 2) + 3 ∧ IsClosenessTester (closenessFlatteningTester m k ε) ε

Sample complexity of closeness testing [Chan–Diakonikolas–Valiant–Valiant] [CDVV14]: on a nonempty domain of size n, for every 0 < ε there is a closeness tester with proximity ε using m + k ≤ 520 max(n^{2/3} ε^{-4/3}, √n ε^{-2}) + 3 samples of each distribution, namely the flattening tester with m = ⌈min(n, n^{2/3} ε^{-4/3})⌉.