aboutsummaryrefslogtreecommitdiff
path: root/FEAST/MIToolbox/cmi.m
blob: 30e4bb02764c0aac4fb6519bc5d0015d9f1ebfa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function output = cmi(X,Y,Z)
%function output = cmi(X,Y,Z)
%X, Y & Z can be matrices which are converted into a joint variable
%before computation
%
%expects variables to be column-wise
%
%returns the mutual information between X and Y conditioned on Z, I(X;Y|Z)

if nargin == 3
  if (size(X,2)>1)
	  mergedFirst = MIToolboxMex(3,X);
  else
	  mergedFirst = X;
  end
  if (size(Y,2)>1)
	  mergedSecond = MIToolboxMex(3,Y);
  else
	  mergedSecond = Y;
  end
  if (size(Z,2)>1)
	  mergedThird = MIToolboxMex(3,Z);
  else
	  mergedThird = Z;
  end
  [output] = MIToolboxMex(8,mergedFirst,mergedSecond,mergedThird);
elseif nargin == 2
  output = mi(X,Y);
else
  output = 0;
end