Joint Entropy of audio files

筅森魡賤 提交于 2019-12-13 01:06:55

问题


So, after trying a heavy cicle-based function for calculating the joint entropy of two sources of information, 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 the information sources, 1xN arrays. This worked just fine with examples in which both sources had only positive integer values, but then I tried to use it with audio files (i.e., arrays whose values ranged from -1 to 1) and it kept giving me an error. I tried adding 1 to each array (to range from 0 to 2), multiplying them by 100 and rounding the numbers, in order to obtain non-negative integers, but it still doesn't work.

Any idea/ alternative to this code would be greatly appreciated.

来源:https://stackoverflow.com/questions/26512778/joint-entropy-of-audio-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!