This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/projects/project_mutualinfo/solution/mi.m

9 lines
206 B
Matlab

function I = mi(nxy)
pxy = nxy / sum(nxy(:));
px = sum(nxy, 2) / sum(nxy(:));
py = sum(nxy, 1) / sum(nxy(:));
pi = pxy .* log2(pxy./(px*py));
pi(nxy == 0) = 0.0;
I = sum(pi(:));
end