Last active
April 1, 2018 00:53
-
-
Save kunigami/0cfb5bba74589f875a4f87579130727b to your computer and use it in GitHub Desktop.
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
const LARGE_ESTIMATE_THRESHOLD: f64 = 143165576.53333333; | |
const TWO_TO_32: f64 = 4294967296.0; // 2^32 | |
if estimate <= 2.5 * m_multiplier { | |
// Small range correction | |
let mut buckets_with_zero = 0; | |
for first_non_zero in first_non_zero_by_experiment { | |
if first_non_zero == 0 { | |
buckets_with_zero += 1; | |
} | |
} | |
if buckets_with_zero > 0 { | |
estimate = m_multiplier * (m_multiplier / (buckets_with_zero as f64)).ln(); | |
} | |
} else if estimate > LARGE_ESTIMATE_THRESHOLD { | |
// Large range correction | |
estimate = -TWO_TO_32 * (1.0 - estimate/TWO_TO_32).ln(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment