# Calculating entropy of a binary matrix

Given a matrix whose entries consist of only 1's and 0's, I would like to come up with a measure of how "ordered" the matrix is, in some sense. This exact question was posed here:

Measuring entropy/ information/ patterns of a 2d binary matrix

in which the top-rated answer posted by whuber provided what I'm looking for, except that I didn't understand one key detail. Referring to his answer, he writes: 'Let's measure this randomness with their base-2 entropy. For $a_1$, the sequence of these entropies is $(1.92, 1.5, 1.58, 1.0)$. Let's call this the "profile" of $a_1$.'

Unfortunately, I've tried but failed to come up with the same entropy values, so I'd appreciate it if I could get some help on how to arrive at those numbers.

• Did you find a solution? Commented Mar 17, 2014 at 10:01
• I'd just like to tack on a point of interest; whuber and Cosmo Harrigan have provided excellent answers to this question but I would also encourage you to reframe this as a graph problem. Graph entropy has quite a bit of literature about this and approaches the exact same problem from a different viewpoint: imagine that this matrix defines the connections between nodes. This may make it a little bit easier to understand. For reference, here's a link that discusses this. visualab.org/index.php/… Commented Jul 9, 2015 at 23:26