This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/linearalgebra/code/pca2dexamples.m

28 lines
551 B
Matlab

% correlation coefficients:
n = 10000;
x = randn( n, 1 );
f = figure( 1 );
for r = 0.01:0.19:1
fprintf( 'Correlation = %g\n', r );
clf( f );
y = r*x + sqrt(1-r^2)*randn( n, 1 );
pca2d( x, y, 0, 5.0, 3.0 );
pause( 1.0 );
end
% two distributions:
n = 10000;
x1 = randn( n/2, 1 );
y1 = randn( n/2, 1 );
x2 = randn( n/2, 1 );
y2 = randn( n/2, 1 );
f = figure( 1 );
for d = 0:1:5
fprintf( 'Distance = %g\n', d );
clf( f );
x = [ x1+d; x2-d ];
y = [ y1+d; y2-d ];
pca2d( x, y, 0, 10.0, 7.0 );
pause( 1.0 );
end