The Jaccard similarity measures the fraction of shared elements between set. In particular, given set and , the Jaccard similarity between them is defined as
The naive calculation of has time complexity by scanning all elements in the two sets once. Here we discuss how randomization might save time.
Lemma One
If we select an item uniformly at random from , then .
Define the random variable
Then we see that is an unbiased estimator of , i.e., .
Suppose that we have a sequence of i.i.d. copies of , denoted , then the average is also an unbiased estimator of . Moreover, by law of large number, as . The problem is, how many 's are enough.
The answer depends on a few factors:
- Whether the value of the required error is relative to or independent to .
- What is the tolerance of failure probability.
In the following discussion we consider only the case of finding an estimator such that with probability at least , where both and are given parameters. Then the convergence behavior with respect to the number of samples can be captured by Hoeffding inequality:
Solving the equation gives
Or equivalent, when we interpret as the width of confidence interval,
which has order .