load thymusglandweights.dat
x = thymusglandweights(1:50);

m = 500;
n = length(x);
x = sort(x);
me = zeros(m,1);
for i = 1:m
    me(i) = mean(x(randi(n,n,1)));
end

a1 = tinv(0.025,n-1);
a2 = tinv(1-0.025,n-1);

se = std(x)/sqrt(n);

fprintf('bootstrap quantiles: %.4f, %.4f \n', quantile(me,0.025), quantile(me,1-0.025));
fprintf('analytical quantile: %.4f, %.4f \n', mean(x)+a1*se, mean(x)+a2*se);

