% % Written by: % -- % John L. Weatherwax 2008-02-20 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- n = 100; x = rand(1,n); % <- a uniform distribution xs = sort(x); % the quantiles we desire to compute: p = [ 0.33 0.4 0.63 0.9 ]; % convert to indices into the order statistics: ind = floor(p*n+0.5); % get the quantiles: q = xs(ind); % print the empirical quantiles: for ti=1:length(p), fprintf('For %10d points the %10.5f quantile is approximated with index %10d with value %10.5f\n',n,p(ti),ind(ti),q(ti)); end