MinHash and the Jaccard similarity #
A permutation σ of a finite linear order α ranks the elements of α. The MinHash of a finite
set A is the least rank min σ(A), with ⊤ for the empty set (Cslib.Probability.minHash).
Broder's theorem ([Bro97]; [LRU20], Section 3.3.3) states that, for a
uniformly random permutation, two sets have equal MinHash values with probability exactly their
Jaccard similarity |A ∩ B| / |A ∪ B| (Cslib.Probability.collisionProb_minHash). The Jaccard
similarity of two empty sets is taken to be 1 (Cslib.Probability.jaccard), which makes the
identity unconditional.
Under a random permutation each element of A ∪ B is equally likely to have the least rank:
transposing two elements is a bijection between the permutations ranking either one first. The
MinHash values agree exactly when the element of least rank lies in A ∩ B.
Consequently MinHash is a (d₁, d₂, 1 - d₁, 1 - d₂)-sensitive family for the Jaccard distance
1 - J ([LRU20], Section 3.6.2; isLocalitySensitive_minHash). Banding
b bands of r MinHash rows gives the S-curve 1 - (1 - J ^ r) ^ b
([LRU20], Section 3.4.2; orCollisionProb_andHash_minHash). Charikar's
triangle inequality gives the triangle inequality for the Jaccard distance
(jaccard_triangle); with jaccard_comm and jaccard_eq_one_iff, the Jaccard distance is a
metric on finite sets.
The random permutation is a uniformly random element of the full symmetric group Equiv.Perm α.
Smaller min-wise independent families and the hash-based approximations used in practice are not
treated here.
Main definitions #
Cslib.Probability.minHash: the least rank of a finite set under a permutation.Cslib.Probability.jaccard: the Jaccard similarity|A ∩ B| / |A ∪ B|, withJ(∅, ∅) = 1.
Main results #
Cslib.Probability.collisionProb_minHash: Broder's theoremPr[minHash σ A = minHash σ B] = J(A, B).Cslib.Probability.isLocalitySensitive_minHash: sensitivity for the Jaccard distance.Cslib.Probability.orCollisionProb_andHash_minHash: the banding S-curve for MinHash.Cslib.Probability.jaccard_eq_one_iff:J(A, B) = 1exactly whenA = B.Cslib.Probability.jaccard_triangle: the triangle inequality for the Jaccard distance, on any type with decidable equality.
References #
The Jaccard similarity |A ∩ B| / |A ∪ B| of two finite sets, with J(∅, ∅) = 1.
Two finite sets have Jaccard similarity 1 exactly when they are equal, so the Jaccard
distance 1 - J separates points.
The Jaccard similarity is invariant under embeddings.
The MinHash of a finite set A under the ranking σ: the least rank min σ(A), or ⊤ when
A is empty.
An element of least rank in A attains the MinHash of A.
Broder's theorem ([Bro97]; [LRU20], Section 3.3.3): under a
uniformly random permutation of α, two finite sets have equal MinHash values with probability
exactly their Jaccard similarity.
MinHash is (d₁, d₂, 1 - d₁, 1 - d₂)-sensitive for the Jaccard distance 1 - J
([LRU20], Section 3.6.2).
Banding MinHash signatures ([LRU20], Section 3.4.2): b bands of
r independent MinHash rows agree in some band with probability 1 - (1 - J ^ r) ^ b.
The Jaccard distance 1 - J satisfies the triangle inequality, by Charikar's argument
([Cha02], Lemma 1) applied to MinHash. The three sets are moved into the finite universe
A ∪ B ∪ C, ordered arbitrarily, where Broder's theorem applies.