function IGR = infoGain(y1,y2)
% IG = infoGainRatio(y1,y2)
%
% y1,y2 binary vectors of class labels
%
% Compute information gain ratio

if nargin < 2
	error('Too few input parameters.');
end

IGR = infoGain(y1,y2)/entropy(y1, y2);


function H = entropy(n_pos, n_neg)
% entropy

H = 0;
if n_pos <= 0 || n_neg <= 0
	return
end
n = n_pos + n_neg;

 H = -n_pos/n * ld(n_pos/n) - n_neg/n * ld(n_neg/n);


function y = ld(x)
% logarithmus dualis

y = log(x)/log(2);
