% This is how to calculate the standard error and 95% confidence limits on % the median using the nonparametric bootstrap method in Matlab. % Note that by default Matlab reports bias corrected percentile % (BCA) confidence limits; these are more accurate than those % obtained using the standard percentile method. data=[6;3;5;2;3;7;4;7;4;10]; % you can also load your data from a file using the load() command B=100000; % desired number of bootstrap resamplings [bootstat,bootsam]=bootstrp(B,@median,data); % calculate the medians on 10 000 bootstrap resampled datasets (returned as bootstat, bootsam gives the actual resampled data) hist(bootstat,16) % make a histogram of the medians calculated on the bootstrap resampled datasets title('Distribution of medians calculated on bootstrap resampled data') % histogram title med=median(data) % the median of the original data sterror=std(bootstat) % the standard error on the median calculated as the standard deviation of the medians calculated on the bootstrapped datasets conflimsBCA=bootci(B,{@median,data},'alpha',0.05,'type','bca') % the BCA corrected 95% bootstrap confidence limits conflimsPERC=bootci(B,{@median,data},'alpha',0.05,'type','per') % the 95% bootstrap confidence limits, calculated using the basic percentile method (in this case the result is the same)