This repository has been archived on 2021-05-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
scientificComputing/statistics/code/bootstrapsem.m
2015-10-20 01:43:18 +02:00

24 lines
418 B
Matlab

nsamples = 1000
resample = 500
x = randn( nsamples, 1 );
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)]);