[bootstrap] improved code
This commit is contained in:
parent
e1c6c32db0
commit
430bdfb7fd
@ -1,7 +1,7 @@
|
||||
nsamples = 100;
|
||||
nresamples = 1000;
|
||||
|
||||
% draw a SRS (simple random sample, "Stichprobe") from the population:
|
||||
% draw a simple random sample ("Stichprobe") from the population:
|
||||
x = randn(1, nsamples);
|
||||
fprintf('%-30s %-5s %-5s %-5s\n', '', 'mean', 'stdev', 'sem')
|
||||
fprintf('%30s %5.2f %5.2f %5.2f\n', 'single SRS', mean(x), std(x), std(x)/sqrt(nsamples))
|
||||
@ -15,7 +15,8 @@ for i = 1:nresamples % loop for generating the bootstraps
|
||||
end
|
||||
fprintf('%30s %5.2f %5.2f -\n', 'bootstrapped distribution', mean(mus), std(mus))
|
||||
|
||||
% many SRS (we can do that with the random number generator, but not in real life!):
|
||||
% many SRS (we can do that with the random number generator,
|
||||
% but not in real life!):
|
||||
musrs = zeros(nresamples,1); % vector for the means of each SRS
|
||||
for i = 1:nresamples
|
||||
x = randn(1, nsamples); % draw a new SRS
|
||||
|
Reference in New Issue
Block a user