
N=1000;
n=1:N;

mode = 2;

if mode == 0
    %%% Gaussian
    w = random('norm',0,1,2,N);
end

if mode == 1
    %%% Exponential
    w = random('exp',1,2,N);
    w = (w-1);
end

if mode == 2
    %%% Unfiform
    w = random('Uniform',-sqrt(3),sqrt(3),2,N);
end

%A = [[1 0]; [0 1]]
%A = [[1 0]; [0 4]]
A = [[1 2]; [1 -2]]

K = A*A'
x = A*w;

[E Lambda] = eig(K)

figure
%scatter(x(1,:),x(2,:),'.')
scatter(x(1,:),x(2,:))
sigma_max = max(K(1,1),K(2,2));

grid on
lim = 2*sigma_max;
lim = 8
axis([-lim lim -lim lim]);
%axis([-6 6 -6 6]);
%hold on

figure
mean=[0 0];
x1 = -lim:.2:lim; 
x2 = -lim:.2:lim;
[X1,X2] = meshgrid(x1,x2);
F = mvnpdf([X1(:) X2(:)],mean,K);
F = reshape(F,length(x2),length(x1));

%contour(x1,x2,F);
% Countours of a Gaussian pdf wit the given covaraince matrix K
contour(x1,x2,F,[.0001 .001 .01 .05:.1:.95 .99 .999 .9999],'Linewidth',1.0);
xlabel('x'); ylabel('y');
axis([-lim lim -lim lim]);
