% % Written by: % -- % John L. Weatherwax 2007-07-01 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- clc; close all; var_scale = 1; cA = mvnrnd( [ -4, -2 ], var_scale*eye(2), 20 ); cB = mvnrnd( [ +20.0, +20.0 ], var_scale*eye(2), 20 ); X = [ cA; cB ]; N = size(X,1); scatter( X(:,1), X(:,2), 25, ones(N,1), 'filled' ); if( 1 ) saveas( gcf, '../../WriteUp/Graphics/Chapter12/dup_fig_12_2_scatter', 'eps' ); end s = 50; % number of monte-carlo samples to take Nsteps = 100; % number of discretization of range [min(d_i,d_j),max(d_i,d_j)] to use q = 40; % maximum possible number of clusters that can be found in this data set [thetas,numFoundClusters] = estimateNumberOfClusters(X,s,Nsteps, q); plot( thetas, mode( numFoundClusters ), '-' ); xlabel('theta'); ylabel('most frequent number of clusters'); axis( [ min(thetas), max(thetas), min(mode(numFoundClusters))-1, max(mode(numFoundClusters))+1 ] ); if( 1 ) saveas( gcf, '../../WriteUp/Graphics/Chapter12/dup_fig_12_2_num_of_clusters', 'eps' ); end