function q = sample_quantiles(x,p) % SAMPLE_QUANTILES - returns the sample quantiles for the given set of data and percentages p % % Input: % x: the input data (one dimensional vector) % p: the quantiles we desire to compute % % 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 = length(x); xs = sort(x); % convert percentiles into indices into the order statistics: ind = floor(p*n+0.5); % get the quantiles: q = xs(ind);