function v = AI_num_pos_examples(examples,a_index,value)
%
% AI_num_pos_examples - get number of positive examples
% Call:
%     n = AI_get_num_pos_examples(ex,ai,v);
% On input:
%     examples (mxn array): training examples
%     a_index (scalar): index of attribute considered
%     value (scalar): value of attribute to consider
% On output:
%     v (scalar): number of positive examples with attribute value
% Custom functions used:
%     none
% Author:
%     T. Henderson, UU, 11/2002
% Method:
%      

[num_examples, num_cols] = size(examples);
if a_index == 0   % consider all examples
   v = sum(examples(:,num_cols));
else
   v = 0;
   for e = 1:num_examples
      if (examples(e,num_cols-1)==1) ...
            & (examples(e,a_index)==value) ...
            & (examples(e,num_cols)==1)
         v = v+1;
      end
   end
end
