Function get_alpha

Source
pub const fn get_alpha(number_of_registers: usize) -> f32
Expand description

Computes the alpha constant for the given number of registers.

The alpha constant is used to scale the raw HyperLogLog estimate into an estimate of the true cardinality of the set.

§Arguments

  • NUMBER_OF_REGISTERS: The number of registers in the HyperLogLog data structure.

§Returns

The alpha constant for the given number of registers.

§Examples


let alpha_16 = get_alpha(16);
let alpha_32 = get_alpha(32);
let alpha_64 = get_alpha(64);

assert_eq!(alpha_16, 0.673);
assert_eq!(alpha_32, 0.697);
assert_eq!(alpha_64, 0.709);

let alpha_4096 = get_alpha(4096);

assert_eq!(alpha_4096, 0.7213 / (1.0 + 1.079 / 4096.0));