36 lines
801 B
Matlab
36 lines
801 B
Matlab
scrsz = get( 0, 'ScreenSize' );
|
|
set( 0, 'DefaultFigurePosition', [ scrsz(3)/2 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2 ] );
|
|
|
|
% correlation coefficients:
|
|
n = 10000;
|
|
x = randn( n, 1 );
|
|
f = figure( 1 );
|
|
for r = 0.01:0.199:1
|
|
fprintf( 'Correlation = %g\n', r );
|
|
clf( f );
|
|
y = r*x + sqrt(1-r^2)*randn( n, 1 );
|
|
covareigen( x, y, 2, 5.0, 3.0 );
|
|
key = waitforbuttonpress;
|
|
end
|
|
return
|
|
|
|
% 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 );
|
|
pause( 'on' );
|
|
for d = 0:1:5
|
|
fprintf( 'Distance = %g\n', d );
|
|
clf( f );
|
|
d2 = d / sqrt( 2.0 );
|
|
x = [ x1; x2 ];
|
|
y = [ y1+d2; y2-d2 ];
|
|
scrsz = get(0,'ScreenSize');
|
|
covareigen( x, y, 1, 10.0, 7.0 );
|
|
%key = waitforbuttonpress;
|
|
pause( 1.0 );
|
|
end
|