This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/statistics/code/bootstraptymus.m

25 lines
456 B
Matlab

resample = 500
load( 'thymusglandweights.dat' );
x = thymusglandweights;
nsamples = length( x );
sem = std(x)/sqrt(nsamples);
mu = zeros( resample, 1 );
for i = 1:resample
% resample:
xr = x(randi(nsamples, nsamples, 1));
% compute statistics on sample:
mu(i) = mean(xr);
end
bootsem = std( mu );
hold on
hist( x, 20 );
hist( mu, 20 );
hold off
disp(['bootstrap standard error: ', num2str(bootsem)]);
disp(['standard error: ', num2str(sem)]);