% % Problem EPage 392 % % Examples 9.7 % % 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. % %----- % % use hold-one-out cross validation to estimate the probability of error % 1) using a parametric approach (multi-dimensional Gaussian) % %forge=forge(:,1); genuine=genuine(:,1); %forge=forge(:,2); genuine=genuine(:,2); %forge=forge(:,3); genuine=genuine(:,3); %forge=forge(:,4); genuine=genuine(:,4); ncc = 0; [nc_f,d] = size(forge); [nc_g,d] = size(genuine); n = nc_f + nc_g; % freeze the estimate of the FORGED data: % mu_f = mean(forge); cv_f = cov(forge); for i=1:nc_g, % create a classifier WITHOUT the genuine point "i": genuine_train = genuine; x = genuine(i,:); genuine_train(i,:)=[]; mu_g = mean(genuine_train); cv_g = cov(genuine_train); p_g = mvnpdf( x, mu_g, cv_g ); p_f = mvnpdf( x, mu_f, cv_f ); if( p_g > p_f ) % <- genuine WINS ncc=ncc+1; else % <- genuine LOOSES ... do nothing % end end % freeze the estimate of the GENUINE data: % mu_g = mean(genuine); cv_g = cov(genuine); for i=1:nc_f, % create a classifier WITHOUT the forge point "i": forge_train = forge; x = forge(i,:); forge_train(i,:)=[]; mu_f = mean(forge_train); cv_f = cov(forge_train); p_g = mvnpdf( x, mu_g, cv_g ); p_f = mvnpdf( x, mu_f, cv_f ); if( p_g < p_f ) % <- forge WINS ncc=ncc+1; else % <- forge LOOSES ... do nothing % end end pcc = ncc/n; fprintf('using a multidimensional Gaussian we estimate pcc=%10.5f\n',pcc);