Let v=(v1,...,vd)∈Rd be a vector, such that ∃ some positive integer M, ∀i∈[d],vi∈[M]. Assume that d is very large and v is sparse, so it is represented by a set of pairs that record the non-zero positions and values of v:
S(v)≐{(i,vi):vi=0,∀i∈[d]}.
A fingerprint h(v)∈R is a succinct summary of v, which can be used to test whether two vectors v,u∈Rd are equal.
Goal: For a given δ∈(0,1), find an h:Rd→R, such that, ∀v,u∈Rd, if v=u, then
Pr[h(v)=h(u)]≤δ.
Solution
Theorem. Let p≥max{d/δ,M} be a prime number and let a be an integer generated from 1 to p−1 uniformly at random. Then
h(v)≐i∈[d]∑vi⋅ai
satisfies the goal.
Remark. It is easy to see that fingerprint is a linear summary:
h(v)=[a,a2,…,ad]v1,v2,⋮vd.
Proof.∀v,u∈Rd, if v=u, if h(v)=h(u), then
i∈[d]∑(vi−ui)⋅ai=0.
However, the polynomial p(x)≐∑i∈[d](vi−ui)⋅xi has at most d distinct roots. As p(0)=0, it has at most d−1 distinct non-zero root. The probability that a=0 being one of them is bounded by
Pr[a is a root of p(x)]=p−1d−1≤pd=δ.
□
h(v) can be computed by the following pseudo-codes:
h←0.
For (i,vi)∈S(v):
h←h+vi⋅ai.
Return h.
Reference
[1] G. Cormode and K. Yi, Small Summaries for Big Data, 1st ed. Cambridge University Press, 2020.