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.

  • $\begingroup$ Did you find a solution? $\endgroup$ Commented Mar 17, 2014 at 10:01
  • 1
    $\begingroup$ 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/… $\endgroup$ Commented Jul 9, 2015 at 23:26

1 Answer 1


The results you are referring to can be replicated using the following code:


This code generates the visualizations and includes the calculation of the "profile" (a list of the entropies) of the set of scaled filtered matrices. Note that the specific entropy values have been updated in the original answer.


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.