% % % Written by: % -- % John L. Weatherwax 2009-04-21 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; drawnow; rehash; clc; clear; addpath( '../../Code/eda_data' ); addpath( '../../Code/eda_toolbox' ); addpath( '../Chapter1' ); rho = 0.99; n = 20; z1 = randn(1,n); z2 = rho * z1 + sqrt( 1 - rho^2 ) * randn(1,n); % test that we are generating correlated random variables correctly the (1,2) element should equal rho above: CC = corrcoef( z1, z2 ); fprintf('sample correlation coefficient rho(z1,z2) = %10.6f\n', CC(1,2) ); figure; parallelcoords( [ z1(:), z2(:) ] ); title( 'parallel coordinate plot rho=+1.0' ); saveas( gcf, '../../WriteUp/Graphics/Chapter10/prob_10_11_rho_p1', 'epsc' ); rho = -0.99; n = 20; z1 = randn(1,n); z2 = rho * z1 + sqrt( 1 - rho^2 ) * randn(1,n); % test that we are generating correlated random variables correctly the (1,2) element should equal rho above: CC = corrcoef( z1, z2 ); fprintf('sample correlation coefficient rho(z1,z2) = %10.6f\n', CC(1,2) ); figure; parallelcoords( [ z1(:), z2(:) ] ); title( 'parallel coordinate plot rho=-1.0' ); saveas( gcf, '../../WriteUp/Graphics/Chapter10/prob_10_11_rho_m1', 'epsc' );