% % 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; clc; addpath('../../Code/CSTool'); load lawpop; % <- the total population % get a random sample from the total population of 15: rand('seed',0); ns = 15; %ns = 25; %ns = 50; inds = unidrnd(size(lawpop,1),1,ns); law = lawpop(inds,:); % get the population correlation coefficient: p=cross_corr_fn(lawpop); % estimate the correlation coefficient using our sample t=cross_corr_fn(law); % perform boostrap hypothesis testing to test the hypothesis that H_0: t>0 B = 1000; bootstat = bootstrp( B, @cross_corr_fn, law ); % get the empricial quantiles for the distribution of our statistics: alpha = 0.01; % <- the probability of a type I error ci = quantile( bootstat, [ 0.5*alpha, 1-0.5*alpha ] ); fprintf('for the correlation coefficient (CC)\n'); fprintf('the population CC and sample CC are = (%10.5f,%10.5f)\n',p,t); fprintf('the bootstraped estimate 90%% quantiles of the CC coefficient are = (%10.5f,%10.5f)\n',ci(1),ci(2));