4
$\begingroup$

1). Does it use the Shannon Entropy function? (Not specified in documentation)

2). Does it work on 3D arrays? (Seems to).

3). What are its Min (assume 0) and Max values? (Not specified in documentation).

Thanks,

Phil

$\endgroup$

1 Answer 1

3
$\begingroup$
list = RandomChoice[{a, b, c}, 1000];

tallies = Tally[list]

(* {{b, 316}, {c, 331}, {a, 353}} *)

Base E (default)

Entropy[list] == -Total[#*Log[#] & /@ (tallies[[All, 2]]/Length[list])]

(* True *)

Base 2

Entropy[2, list] == -Total[#*Log2[#] & /@ (tallies[[All, 2]]/Length[list])]

(* True *)

Base 10

Entropy[10, list] == -Total[#*Log10[#] & /@ (tallies[[All, 2]]/Length[list])]

(* True *)

EDIT: The entropy is maximized when all of the choices are equally likely. For n equally likely choices, the entropy is Log[n]/Log[b] where b is the base.

$\endgroup$
2
  • $\begingroup$ Log[Exp[1]] == 1 so why divide by Ln[e]? $\endgroup$ Commented Sep 2, 2022 at 17:46
  • $\begingroup$ Log[n]/Log[b] is the result for an arbitrary positive base. For b == E it does simplify to Log[n]. $\endgroup$
    – Bob Hanlon
    Commented Sep 2, 2022 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.