Shared entropy of audio files
So after trying a heavy cicle based function to calculate the joint entropy of two information sources, I found this useful MATLAB function accumarray
and tried the following code:
function e = jointEntropy(fonte1, fonte2)
i = double(fonte1(:))+ 1;
j = double(fonte2(:)) + 1;
subs = [i j];
f = accumarray(subs, ones(length(fonte1), 1));
p = f / length(fonte1);
freq = f ~= 0;
prob = p(freq);
e = -sum(prob.*log2(prob));
end
where fonte1
and fonte2
are sources of information, arrays 1xN
. This worked very well with examples where both sources only had positive integer values, but then I tried to use it with sound files (i.e. Arrays that ranged from -1 to 1) and it kept giving me an error. I tried adding 1 to each array (0 to 2), multiplying them by 100 and rounding the numbers to get non-negative integers, but it still doesn't work.
Any idea / alternative to this code would be appreciated.
source to share
No one has answered this question yet
See similar questions:
or similar: