Helper function tau as defined in * "New cardinality estimation algorithms for HyperLogLog sketches" * Otmar Ertl, arXiv:1702.01284 */
| 994 | * "New cardinality estimation algorithms for HyperLogLog sketches" |
| 995 | * Otmar Ertl, arXiv:1702.01284 */ |
| 996 | double hllTau(double x) { |
| 997 | if (x == 0. || x == 1.) return 0.; |
| 998 | double zPrime; |
| 999 | double y = 1.0; |
| 1000 | double z = 1 - x; |
| 1001 | do { |
| 1002 | x = sqrt(x); |
| 1003 | zPrime = z; |
| 1004 | y *= 0.5; |
| 1005 | z -= pow(1 - x, 2)*y; |
| 1006 | } while(zPrime != z); |
| 1007 | return z / 3; |
| 1008 | } |
| 1009 | |
| 1010 | /* Return the approximated cardinality of the set based on the harmonic |
| 1011 | * mean of the registers values. 'hdr' points to the start of the SDS |