% % epage 241 % % lawpop % % 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; inds = unidrnd(size(lawpop,1),1,ns); law = lawpop(inds,:); % get the population variances: pop_var_lsat = var(lawpop(:,1)); pop_var_gpa = var(lawpop(:,2)); % estimate the population variance: sam_var_lsat = var(law(:,1)); sam_var_gpa = var(law(:,2)); % get the bootstrapped estimate of the standard error of the variance % B = 4000; % (of the lsat score): bootstat = bootstrp( B, @var, law(:,1) ); fprintf('the population variance and sample variance is = (%10.5f,%10.5f)\n',pop_var_lsat,sam_var_lsat); fprintf('the bootstraped estimate of the SE of the variance of lsat is %10.5f\n', std( bootstat ) ); fprintf('the bootstraped estimate of the bias in the variance of lsat is %10.5f\n', mean( bootstat )-sam_var_lsat ); % (of the gpa): bootstat = bootstrp( B, @var, law(:,2) ); fprintf('the population variance and sample variance is = (%10.5f,%10.5f)\n',pop_var_gpa,sam_var_gpa); fprintf('the bootstraped estimate of the SE of the variance of gpa is %10.5f\n', std( bootstat ) ); fprintf('the bootstraped estimate of the bias in the variance of gpa is %10.5f\n', mean( bootstat )-sam_var_gpa );