MinHash › Accuracy Analysis: How Many Hash Functions Do You Need?
Language AI HandbookAll chapters MinHash › Accuracy Analysis: How Many Hash Functions Do You Need?One section · Sections in this chapter9 / 13 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
The estimation variance of MinHash follows directly from the properties of Bernoulli trials. Each of the positions in the signature independently agrees with probability . The estimated similarity is a sample mean of independent Bernoulli trials with success probability . By standard statistics:
and the standard deviation is:
where:
- : the true Jaccard similarity
- : the number of hash functions
- : the MinHash estimate
The variance is maximized when , giving . At the extremes ( or ), the variance is zero because the answer is known exactly with no uncertainty. For deduplication, the most error-prone regime is when you are near the threshold, which is typically around 0.7 to 0.9 for LLM training pipelines. At , the variance is , somewhat lower than the worst case.
For and , the standard deviation is . A 95% confidence interval spans roughly . For deduplication decisions, you typically only care whether similarity exceeds a threshold (say, 0.8), not the exact value. An error of 0.09 around the threshold means pairs close to the threshold are uncertain, but pairs well above or well below are reliably classified.
# Analyze the accuracy of MinHash estimation as a function of k
def minhash_std(j: float, k: int) -> float:
"""Theoretical standard deviation of MinHash similarity estimate."""
return np.sqrt(j * (1 - j) / k)
k_values = [32, 64, 128, 256, 512]
jaccard_test = 0.5 # Worst-case variance at J=0.5MinHash estimation standard deviation at J=0.5:
k Std Dev 95% CI width
------------------------------------
32 0.0884 0.3465
64 0.0625 0.2450
128 0.0442 0.1732
256 0.0312 0.1225
512 0.0221 0.0866At hash functions, the 95% confidence interval width is roughly 0.17. At , it narrows to about 0.12. In practice, 128 hash functions is the most common choice: it provides sufficient accuracy for deduplication decisions while keeping memory requirements manageable (512 bytes per document).
Confidence Intervals and Threshold Decisions
The practical question is not "how accurate is the estimate?" but "how likely are we to make the wrong deduplication decision?" If your threshold is and two documents have true similarity , what is the probability that the MinHash estimate falls below 0.8, causing a false negative?
With and , the standard deviation is . The threshold is standard deviations below the true value. The probability of a false negative is approximately , or about 5.5%. Increasing to 256 reduces this to about 1.5%.
This analysis explains why practitioners choose 128 to 256 hash functions rather than fewer: the marginal cost in memory and computation is small, but the reduction in deduplication errors is meaningful.