summaryrefslogtreecommitdiffstats
path: root/test/entropy/CalculateEntropy.m (plain)
blob: 18bfda5edbd3015d963008dcc5d29a3665a666f7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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);

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.