Hyperloglog, Probability, Hash Function, Cardinality Estimation, Dynamic Programming.
r from 0 to n using dynamic programming def ncr(n): cache = [[0]*(n+1) for i in range(n+1)] for i in range(n+1): for j in range(i+1): if j == 0 or i == j: cache[i][j] = 1 else: cache[i][j] = cache[i-1][j] + cache[i-1][j-1] return cache # Compute the term inside the 2nd summation in the expectation