function v = AI_multi_gain(examples,attributes,a_index)
%
% AI_multi_gain - compute info gain for attribute
% Call:
%     v = AI_multi_gain(ex,att,3);
% On input:
%     examples (mxn array): training set
%     attributes (structure array): attributes
%     a_index (scalar): index of attribute
% On output:
%     v (scalar): info gain for attribute
% Custom functions used:
%     none
% Author:
%     T. Henderson
%     UU
%     Fall 2012
%

v = 0;

% Get pi: prob of each class

[num_examples,num_cols] = size(examples);
indexes = find(examples(:,num_cols-1)==1);
if isempty(indexes)
    return
end

ex_available = examples(indexes,:);
p = AI_prob_examples(ex_available);
v = AI_entropy(p) - AI_multi_remainder(ex_available,attributes,a_index);
