% Chad Myers
% ELE 571
% File: test_bp.m
% ------------------------
% This file contains the test_bp script which calls bptrain for a XOR dataset
% to demonstrate the use of the bptrain function.


num_clusters=4;
n=70;
iter=50;
rbf=1;

class1_id = 1;
class2_id = -1;


%randomly generate XOR training data and desired result in the window given by x E [-1,1], y E
%[-1,1]

for i=1:n,
    temp1 = 2*rand(2);
    temp2 = rand(2);
    
    if(temp1(1) > 1) data(i,1) = temp1(2);
    else data(i,1) = -temp1(2);
    end
        
    if(temp2(1) > .5) data(i,2) = temp2(2);
    else data(i,2) = -temp2(2);
    end
    
    if(abs(data(i,2)) > .5*abs(data(i,1))) desired(i,1) = class1_id;
    else desired(i,1) = class2_id;
    end
end

[ind1,ind2] = find(desired == 1);
class1 = data(ind1,:);
[ind1,ind2] = find(desired == -1);
class2 = data(ind1,:);




[W,means,sigma,correct] = bptrain(class1,class2,num_clusters,iter,rbf);