Created
April 29, 2013 19:09
-
-
Save abramsm/5483928 to your computer and use it in GitHub Desktop.
example HLL+ for different p values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int p = 10; p < 18; p++) | |
{ | |
HyperLogLogPlus hyperLogLogPlus = new HyperLogLogPlus(p, 25); | |
int count = 4200000; | |
for (int i = 0; i < count; i++) | |
{ | |
hyperLogLogPlus.offer("i" + i); | |
} | |
long estimate = hyperLogLogPlus.cardinality(); | |
double se = count * (1.04 / Math.sqrt(Math.pow(2, p))); | |
long expectedCardinality = count; | |
double error = (count - estimate) / (double) count; | |
System.out.println("Expect estimate for p=" + p + " is " + estimate + " with error: " + error + " is between " + (expectedCardinality - (3 * se)) + " and " + (expectedCardinality + (3 * se)) + " mem:" + hyperLogLogPlus.getBytes().length); | |
assertTrue(estimate >= expectedCardinality - se); | |
assertTrue(estimate <= expectedCardinality + se); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment