The warning was due to a divide by zero. The log was zero because N is equal to one so $\log N = \log 1 = 0$.
But, when $N=1$ the entropy $S$ also is 0 because the formula for entropy reduces to:
$$S = p(x) \times \log p(x)$$
but since $p(x) = 1$, because we only have one element, then we have:
$$S = 1 \times 0 = 0$$
In short, when N is 1 then S is 0 so S / N must be 0 too, which is the solution implemented here.
Fixes #5.
The warning was due to a divide by zero. The log was zero because
N
is equal to one so $\log N = \log 1 = 0$.But, when $N=1$ the entropy $S$ also is 0 because the formula for entropy reduces to: $$S = p(x) \times \log p(x)$$ but since $p(x) = 1$, because we only have one element, then we have: $$S = 1 \times 0 = 0$$ In short, when N is 1 then S is 0 so S / N must be 0 too, which is the solution implemented here.