function [patterns,labels] = gen_data_pt_b(nSamples,dim) % GEN_DATA_PT_B - Generates simulated classification data according to the sum of % the squares of "dim" standard normal random variables % % Written by: % -- % John L. Weatherwax 2007-07-05 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- % generate "nSamples" from "dim" independent Gaussians: % patterns = randn( nSamples, dim ); % square and sum (these are now samples from a chi^2 random variable with dim degrees of freedom): dt = sum( patterns.^2, 2 ); % calculate the threshold: for classification (if dim=10 then ct ~ 9.3) ct = chi2inv( 0.5, dim ); indsGT = find( dt > ct ); indsLT = find( dt <= ct ); labels(indsGT) = 1; labels(indsLT) = -1;