MATLAB: How to put this into matlab code form

entropy

The m-block entropy of a sequence X is defined as N Hm(X) = − p(m) log2(p(m)) ii i=1. I am not sure how to put this into code form as I don't know how to do block entropy

Best Answer

Given an "m" vector of indices, and the full vector "p":
HmX = p(m) .* log2(p(m))