Use llroundl() before converting loglog-beta output to integer.
Otherwise for small cardinalities the algorithm will output something like, for example, 4.99 for a candinality of 5, that will be converted to 4 producing a huge error.
Please register or sign in to comment