load thymusglandweights.dat

n = 16;
x = thymusglandweights(1:n);

m = 5000;
me = zeros(m,1);
for i = 1:m
    me(i) = median(x(randi(n,n,1)));
end

t025 = tinv(0.025, n-1);
t975 = tinv(0.975, n-1);

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

fprintf('bootstrap quantiles: %.4f, %.4f \n', quantile(me,0.025), quantile(me,0.975));
fprintf('analytical quantile: %.4f, %.4f \n', mean(x)+t025*se, mean(x)+t975*se);

