function OUT_VEC = CalculateEntropy(ARRAY) % CalculateEntropy % Calculate the Informationational Entropy of each position in a % multialignment. In this function I remove all gap characters from % each column of the alignment before doing the calculation. % % % num_array = aa2int(ARRAY); bins = histc(num_array, 0:21, 1); probs=bsxfun(@rdivide, bins(2:end-1,:),sum(bins(2:end-1,:))); OUT_VEC = -nansum(log(probs).*double(probs~=0).*probs);