
function [bestx] = train_cart_leavenode(feat_class1, feat_class2)


% find the x which maximizes the information gain
bestig = -Inf;
bestx = [ 0 0 0];
for i = 1:100 % generate 100 random lines
    % draw sample
    sample = rand([2 1]);
    % this is the line equation in hessian normal form
    x = [cos(sample(1)*pi) -sin(sample(1)*pi) 2*(sample(2)-0.5)]; 
    % compute information gain
    ig = information_gain(feat_class1, feat_class2, x);
    % better than best previous information gain ?
    if( ig > bestig)
        % keep solution
        bestx = x;
        bestig = ig; 
    end;
end


end