function clusters()

%generate clusters
c1 = [ [5  2] ; [2  2] ];
m1 = [1  1.5];
n1 = 300;

c2 = [ [1  -1] ; [-1  5] ];
m2 = [-3  -1];
n2 = 400;

c3 = [ [1  0] ; [0  1] ];
m3 = [3  -3];
n3 = 300;


Y1 = gencluster(m1,c1,n1);
Y2 = gencluster(m2,c2,n2);
Y3 = gencluster(m3,c3,n3);

norm = n1+n2+n3;

C1 = cov(Y1);
m1 = mean(Y1);
p1 = n1/norm;

C2 = cov(Y2);
m2 = mean(Y2);
p2 = n2/norm;

C3 = cov(Y3);
m3 = mean(Y3);
p3 = n3/norm;


%print pdf
h = figure;

[X,Y] = meshgrid(-8:0.1:8);

CINV1 = inv(C1);
CINV2 = inv(C2);
CINV3 = inv(C3);


Z =     p1 * gpdf2D(X,Y,m1(1,1),m1(1,2),CINV1)...
    +   p2 * gpdf2D(X,Y,m2(1,1),m2(1,2),CINV2)...
    +   p3 * gpdf2D(X,Y,m3(1,1),m3(1,2),CINV3);

%subplot(1,2,1);

%plot cluster1
plot(Y1(:,1),Y1(:,2),'o');
hold on
plot(Y2(:,1),Y2(:,2),'+');
plot(Y3(:,1),Y3(:,2),'.');
title('scatterplot');
hold off

%subplot(1,2,2);
figure;

surf(X,Y,Z,'FaceColor','red','EdgeColor','none');
title('parametric PDF');
camlight right;
lighting phong
view(10,60);

