generate a vector with 1'000 random integers from [0, 20]. then, apply the nonparametric bootstrap algorithm with 999 replications to estimate the standard deviation of the mean of the vector. in matlab

You can generate a vector with 1,000 random integers from [0, 20] using the following code:

vec = randi([0, 20], 1, 1000);
31 chars
2 lines

To apply the nonparametric bootstrap algorithm with 999 replications to estimate the standard deviation of the mean of the vector, you can use the following code:

n = length(vec); % sample size
B = 999; % number of bootstrap samples
means = zeros(B, 1); % preallocate vector for bootstrap means
for i = 1:B
    % generate bootstrap sample by sampling with replacement from original sample
    bootstrap_sample = datasample(vec, n);
    % calculate mean of bootstrap sample and store it in means vector
    means(i) = mean(bootstrap_sample);
end
% compute standard deviation of the means vector
std_of_means = std(means);
458 chars
12 lines

Note that the datasample function is used to sample with replacement from the original sample to create the bootstrap sample. The mean of each bootstrap sample is stored in the means vector, which is used to compute the standard deviation of the means using the std function.

gistlibby LogSnag