Solved – Calculating entropy of a binary matrix

entropyinformation theorymatrix

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.

Best Answer

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

https://github.com/cosmoharrigan/matrix-entropy

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.