These are the human proofs of SimHash, at full length.
SimHash bits are random hyperplane bits, and their Hamming distance concentrates around θ/π full
This proof shows: correctness.
We use the names of the pseudocode on the page. A document is a finite set F of features with weights w(f)>0, viewed as the vector x with xf=w(f) on F and xf=0 on the other features.
Lemma 1 (the counters). For the ±1 version, after the loop of line L2, V[i]=∑f∈Fw(f)σi(f), where σi(f)=+1 if bit i of H(f) is 1 and −1 otherwise. For the Gaussian variant, V[i]=∑f∈Fw(f)gi(f).
Proof. Line L1 sets V[i]=0. Line L5, executed once for each pair (f,i), adds w(f)σi(f) to V[i] and changes no other counter. Addition is commutative, so after all features V[i] is the sum. The Gaussian variant is the same with gi(f). □
So bit i of the fingerprint is 1 exactly when x⋅σi>0 (or x⋅gi>0), where σi=(σi(f))f. For two documents x and y, only the features in G=Fx∪Fy matter, so we work in RG.
Theorem 1 (Gaussian variant). Assume that the values gi(f), for f∈G and 1≤i≤b, are independent N(0,1). Let θ be the angle between x and y in RG, and let Xi=1 if bit i of the two fingerprints differs. Then the Xi are independent, Pr[Xi=1]=θ/π, and the Hamming distance D=∑iXi satisfies E[D]=bθ/π and Pr[∣D/b−θ/π∣≥ε]≤2e−2bε2 for every ε>0.
Proof. Fix i. The vector gi=(gi(f))f∈G has independent N(0,1) coordinates. By Lemma 1 of the proof on the random hyperplane LSH page, the events gi⋅x≥0 and gi⋅y≥0 disagree with probability θ/π. Line L6 uses >0 instead of ≥0; the two rules differ only when gi⋅x=0 or gi⋅y=0, and each is a linear form with a nonzero coefficient vector in Gaussian variables, which is 0 with probability 0. So Pr[Xi=1]=θ/π. The variable Xi is a function of gi alone, and the vectors g1,…,gb are independent, so the Xi are independent. Linearity of expectation gives E[D]=bθ/π. The Xi take values in [0,1], so Hoeffding's inequality gives Pr[∣D−ED∣≥bε]≤2exp(−2(bε)2/b)=2e−2bε2. □
Theorem 2 (±1 version). Assume that the bits of H(f), for f∈G and all positions, are independent fair coins. Then the Xi are independent and identically distributed with some probability δ(x,y)=Pr[Xi=1] that does not depend on i, E[D]=bδ, and Pr[∣D/b−δ∣≥ε]≤2e−2bε2. In general δ(x,y)=θ/π.
Proof.Xi is the same function of the vector σi=(σi(f))f∈G for every i, and σ1,…,σb are independent and identically distributed, uniform on {−1,+1}G. So the Xi are independent with a common mean δ, and the expectation and the Hoeffding bound follow as in Theorem 1. For the last claim take G={1,2,3}, x=(1,0,0) and y=(1,1,1). Bit i of x is 1 when σi(1)=+1; bit i of y is 1 when σi(1)+σi(2)+σi(3)>0, that is, when at least two of the three signs are +1. The two bits disagree exactly when σi(2) and σi(3) are both opposite to σi(1), which has probability 1/4. So δ=1/4, while θ/π=arccos(1/3)/π≈0.3041. ■