function v = AI_multi_remainder(examples,attributes,a_index)
%
% AI_multi_remainder - compute info remaining after attribute
% Call:
%     v = AI_multi_remainder(ex,atts,2);
% On input:
%     examples (mxn array): examples for training
%     attributes (structure array): attributes
%     a_index (scalar): attribute index for remainder
% On output:
%     v (scalar): info remainder on this attribute
% Custom functions used:
%     none
% Author:
%     T. Henderson
%     UU
%     Fall 2012
%      

[t,num_cols] = size(examples);
a_values = attributes(a_index).values;
H_sum = 0;

for val = 0:length(a_values)-1
    ex_a = AI_get_att_examples(examples,a_index,val);
    if isempty(ex_a)
        pi = 0;
        ti = 0;
    else
        pi = AI_prob_examples(ex_a);
        [ti,num_cols] = size(ex_a);
        info_content = AI_entropy(pi);
        H_sum = H_sum + (ti/t)*info_content;
    end
end
v = H_sum;
