Documentation

CslibFrontier.Probability.IID.CollisionCount

Collision counts of independent samples #

Cslib.Probability.PMF.collisionCount x is the number of pairs i < j of sample positions with x i = x j. Among k independent draws from μ it has mean C(k, 2) ‖μ‖₂², where ‖μ‖₂² = ∑ a, μ(a)² is the collision probability (sum_iid_mul_collisionCount), and, writing s = ‖μ‖₂² and t = ∑ a, μ(a)³, variance exactly C(k, 2) (s - s²) + k (k - 1) (k - 2) (t - s²) (sum_iid_mul_collisionCount_sub_sq). These are the moments behind the collision tester for uniformity Goldreich–Ron. The mean is Diakonikolas–Gouleakis–Peebles–Price, Lemma 2 and the variance identity is the equality chain in the proof of Diakonikolas–Gouleakis–Peebles–Price, Lemma 3 (numbering of arXiv:1611.03579v1), the basis of their sharp analysis.

The proof inducts on the number of samples, peeling off the first draw (sum_iid_succ_mul), and tracks the joint moments of the collision count and the occurrence counts of single values (occurrenceCount, both from CslibFrontier.Probability.IID.Occurrence). These joint moments are public because the cross-collision count of two independent samples is a sum of products of occurrence counts.

Main definitions #

Main results #

References #

def Cslib.Probability.PMF.collisionCount {α : Type u_1} [DecidableEq α] {k : ℕ} (x : Fin k → α) :

The number of colliding pairs i < j with x i = x j among the samples x.

theorem Cslib.Probability.PMF.sum_iid_mul_collisionCount {α : Type u_1} [Fintype α] [DecidableEq α] (μ : PMF α) (k : ℕ) :
∑ x : Fin k → α, ((iid μ k) x).toReal * ↑(collisionCount x) = ↑(k.choose 2) * collisionProbability μ

Mean of the collision count: among k independent draws from μ, the expected number of colliding pairs is C(k, 2) times the collision probability ∑ a, μ(a)².

theorem Cslib.Probability.PMF.sum_iid_mul_collisionCount_sub_sq {α : Type u_1} [Fintype α] [DecidableEq α] (μ : PMF α) (k : ℕ) :
∑ x : Fin k → α, ((iid μ k) x).toReal * (↑(collisionCount x) - ↑(k.choose 2) * collisionProbability μ) ^ 2 = ↑(k.choose 2) * (collisionProbability μ - collisionProbability μ ^ 2) + ↑k * (↑k - 1) * (↑k - 2) * (∑ a : α, (μ a).toReal ^ 3 - collisionProbability μ ^ 2)

Variance of the collision count: among k independent draws from μ, with s = ∑ a, μ(a)² and t = ∑ a, μ(a)³, the collision count has variance C(k, 2) (s - s²) + k (k - 1) (k - 2) (t - s²).

theorem Cslib.Probability.PMF.sum_iid_mul_occurrenceCount {α : Type u_1} [Fintype α] [DecidableEq α] (μ : PMF α) (b : α) (k : ℕ) :
∑ x : Fin k → α, ((iid μ k) x).toReal * ↑(occurrenceCount x b) = ↑k * (μ b).toReal

Mean of an occurrence count: among k independent draws from μ, the value b occurs k μ(b) times on average.

theorem Cslib.Probability.PMF.sum_iid_mul_occurrenceCount_mul_occurrenceCount {α : Type u_1} [Fintype α] [DecidableEq α] (μ : PMF α) (a b : α) (k : ℕ) :
∑ x : Fin k → α, ((iid μ k) x).toReal * (↑(occurrenceCount x a) * ↑(occurrenceCount x b)) = ↑k * (↑k - 1) * (μ a).toReal * (μ b).toReal + ↑k * if a = b then (μ a).toReal else 0

Joint moment of two occurrence counts among k independent draws from μ: E[N_a N_b] = k (k - 1) μ(a) μ(b) + k [a = b] μ(a).

theorem Cslib.Probability.PMF.sum_iid_mul_collisionCount_mul_occurrenceCount {α : Type u_1} [Fintype α] [DecidableEq α] (μ : PMF α) (b : α) (k : ℕ) :
∑ x : Fin k → α, ((iid μ k) x).toReal * (↑(collisionCount x) * ↑(occurrenceCount x b)) = ↑k * (↑k - 1) * (↑k - 2) / 2 * collisionProbability μ * (μ b).toReal + ↑k * (↑k - 1) * (μ b).toReal ^ 2

Joint moment of the collision count and an occurrence count among k independent draws from μ: E[C N_b] = k (k - 1) (k - 2) ‖μ‖₂² μ(b) / 2 + k (k - 1) μ(b)².

theorem Cslib.Probability.PMF.sum_iid_mul_collisionCount_sq {α : Type u_1} [Fintype α] [DecidableEq α] (μ : PMF α) (k : ℕ) :
∑ x : Fin k → α, ((iid μ k) x).toReal * ↑(collisionCount x) ^ 2 = ↑(k.choose 2) * collisionProbability μ + ↑k * (↑k - 1) * (↑k - 2) * ∑ a : α, (μ a).toReal ^ 3 + ↑k * (↑k - 1) * (↑k - 2) * (↑k - 3) / 4 * collisionProbability μ ^ 2

Second moment of the collision count among k independent draws from μ, with s = ‖μ‖₂² and t = ∑ a, μ(a)³: E[C²] = C(k, 2) s + k (k - 1) (k - 2) t + k (k - 1) (k - 2) (k - 3) s² / 4.