Hyperloglog, Probability, Hash Function, Cardinality Estimation, Dynamic Programming.
For each combination of k1, k2, ..., km for x in out: p = 1 # Mean of the k1, k2, ..., km q = 2**(1.0 + sum(x)/m) for y in x: p *= ((1-(1/2)**(y+1))**n - (1-(1/2)**y)**n) s1 += p*q**2 s2 += p*q print(m) # print standard error print(math.sqrt(s1-s2**2)/math.sqrt(n)) The plot of the standard error