function [best_index,max_gain] = AI_choose_gain(attributes,examples)
%
% AI_choose_gain - choose attribute using info theory
% Call:
%     v = AI_choose_gain(a,e);
% On input:
%     attributes (structure array): attributes
%     examples (mxn array): training set
% On output:
%     a (integer): attribute index chosen
% Custom functions used:
%     none
% Author:
%     T. Henderson, UU, 11/2002
% Method:
%      

num_attributes = length(attributes);
best_index = 0;
max_gain = -1;

for a = 1:num_attributes
   if attributes(a).include==1
      g = AI_multi_gain(examples,attributes,a);
      if g>max_gain
         best_index = a;
         max_gain = g;
      end
   end
end
v = 0;
