%% Test the joint cluster model
clear all;

%Create the data
data{1} = randn(200,2);
data{2} = randn(200,2);

data{1}(101:200,:) = data{1}(101:200,:) + repmat([-4 4],100,1);
data{2}(1:75,:) = data{2}(1:75,:) + repmat([3 -3],75,1);
data{2}(76:125,:) = data{2}(76:125,:) + repmat([0,0],50,1);
data{2}(126:150,:) = data{2}(126:150,:) + repmat(5,25,2);
data{2}(151:200,:) = data{2}(151:200,:) + repmat(-5,50,2);



dataout = data;


data{1} = randn(200,2);
data{2} = randn(200,2);

data{1}(101:200,:) = data{1}(101:200,:) + repmat([-4 4],100,1);
data{2}(1:75,:) = data{2}(1:75,:) + repmat([3 -3],75,1);
data{2}(76:125,:) = data{2}(76:125,:) + repmat([0,0],50,1);
data{2}(126:150,:) = data{2}(126:150,:) + repmat(5,25,2);
data{2}(151:200,:) = data{2}(151:200,:) + repmat(-5,50,2);




% nanpos = rand(200,2) > 0.9;
% data{1}(nanpos) = nan;
% nanpos = rand(200,2)>0.9;
% data{2}(nanpos) = nan;
% 
% nanpos = rand(200,2)>0.9;
% dataout{2}(nanpos) = nan;
% 
% nanpos = rand(200,2)>0.5;
% dataout{1}(nanpos) = nan;
out = jointmix(data,...
    'no_its',500,...
    'covopt','diag',...
    'verbose',2,...
    'outx',dataout,...
    'j',4,...
    'tol',1e-8);