% % Example epage: 28 % Problem epage: 41 % % Written by: % -- % John L. Weatherwax 2008-02-20 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- clear all; close all; drawnow; clc; addpath('../../Code/eda_toolbox'); addpath('../../Code/eda_data'); n = 100; p = 2; X = randn(n,p); orig_dists = pdist(X); figure; odh=plot( sort(orig_dists), 'o' ); hold on; Xz = zscore(X); % <- this implements equation 1.1 z_dists = pdist(Xz); dt1h=plot( sort(z_dists), 'rx' ); Xn1 = X./repmat( std(X), [n,1] ); % <- this implements equation 1.2 ... since mean(X)=0 it is the same ... n1_dists = pdist(Xn1); dt2h=plot( sort(n1_dists), 'kd' ); xlabel( '(i,j) index' ); ylabel( 'distance' ); legend( [odh,dt1h,dt2h], {'original data','Eq 1.1','Eq 1.2'}, 'location', 'northwest' ); title( 'the original distance and the normalized distance' ); saveas( gcf, '../../WriteUp/Graphics/Chapter1/prob_1_8_distances', 'eps' );