I know the definition of entropy of a probability distribution:
$$H = - \sum_i p_i \log p_i $$
So for example, in a Bernoulli distribution with $p = 0.2$, $1-p=0.8$, the entropy is $0.5$. However, in Mathematica
Entropy[{0.2,0.8}]
returns Log[2]
. So either the Mathematica has a bug, or I don't understand what it is that Entropy[...]
calculates in Mathematica. Can someone clarify this for me?
N@Entropy@RandomVariate[BernoulliDistribution[.2], 100000]
$\endgroup$Mean
orVariance
. However, those 2 also do the proper symbolic thing when passed a distribution andEntropy
doesn't. But you can do it by hand, e.g,entropy[dist_] := Expectation[-Log[PDF[dist, \[FormalX]]], \[FormalX] \[Distributed] dist]
? $\endgroup$Entropy[list]
is the same thing asTotal[(-# Log[#] &) /@ (Values@Counts[list]/Length[list])]
. Does this answer your question? $\endgroup$