src/probabilistic/CardinalityCounter.cc
double CardinalityCounter::Size() const
	{
	double answer = 0;
	for ( unsigned int i = 0; i < m; i++ )
		answer += pow(2, -((int)buckets[i]));

	answer = 1 / answer;
	answer = (alpha_m * m * m * answer);

	if ( answer <= 5.0 * (m / 2) )
		return m * log(((double)m) / V);

	else if ( answer <= (pow(2, 64) / 30) )
		return answer;

	else
		return -pow(2, 64) * log(1 - (answer / pow(2, 64)));
	}
/**
 * Estimate the size by using the the "raw" HyperLogLog estimate. Then,
 * check if it's too "large" or "small" because the raw estimate doesn't
 * do well in those cases.
 * Thus, we correct for those errors as specified in the paper.
 *
 * Note - we deviate from the HLL algorithm in the paper here, because
 * of our 64-bit hashes.
 **/
Estimate the size by using the the "raw" HyperLogLog estimate. Then,
check if it's too "large" or "small" because the raw estimate doesn't
do well in those cases.
Thus, we correct for those errors as specified in the paper.

we deviate from the HLL algorithm in the paper here, because
of our 64-bit hashes.
Estimate the size by using the the " raw " HyperLogLog estimate . Then check if it ' s too " large " or " small " because the raw estimate doesn ' t do well in those cases . Thus we correct for those errors as specified in the paper . we deviate from the HLL algorithm in the paper here because of our 64 - bit hashes .
double CardinalityCounter::Size() const
	{
	double answer = 0;
	for ( unsigned int i = 0; i < m; i++ )
		answer += pow(2, -((int)buckets[i]));
	answer = 1 / answer;
	answer = (alpha_m * m * m * answer);
	if ( answer <= 5.0 * (m / 2) )
		return m * log(((double)m) / V);
	else if ( answer <= (pow(2, 64) / 30) )
		return answer;
	else
		return -pow(2, 64) * log(1 - (answer / pow(2, 64)));
	}
double CardinalityCounter :: Size ( ) const { double answer = 0 ; for ( unsigned int i = 0 ; i < m ; i ++ ) answer += pow ( 2 , - ( ( int ) buckets [ i ] ) ) ; answer = 1 / answer ; answer = ( alpha_m * m * m * answer ) ; if ( answer <= 5.0 * ( m / 2 ) ) return m * log ( ( ( double ) m ) / V ) ; else if ( answer <= ( pow ( 2 , 64 ) / 30 ) ) return answer ; else return - pow ( 2 , 64 ) * log ( 1 - ( answer / pow ( 2 , 64 ) ) ) ; }
Estimate the size by using the the "raw" HyperLogLog estimate.
Estimate the size by using the the " raw " HyperLogLog estimate .