34 lines
		
	
	
		
			752 B
		
	
	
	
		
			Matlab
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			752 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.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 );
 | 
						|
    waitforbuttonpress;
 | 
						|
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 );
 | 
						|
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');
 | 
						|
    pca2d( x, y, 0, 10.0, 7.0 );
 | 
						|
    waitforbuttonpress;
 | 
						|
end
 |