Hyperloglog, Probability, Hash Function, Cardinality Estimation, Dynamic Programming.
formula # dp = memoization variable def gn(arr, i, n, m, u, dp): if m == 0: return 0 if n > 0 else 1 s = 0 for j in range(n+1): p = (1-(1/2)**(arr[i]+1))**j - (1-(1/2)**arr[i])**j a = gn(arr, i+1, n-j, m-1, u, dp) if (n-j, m-1) not in dp \ else dp[(n-j, m-1)] s += p*u[n][j]*a dp[(n, m)] = s return