function q = sample_quantiles_linInterp(x,p) % SAMPLE_QUANTILES - returns the sample quantiles for the given set of data and percentages p using linear interpolation % % 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); % the approximate quantiles associated with phat = ((1:n)-0.5)/n; % these approximate values xhat = sort(x); % linearly interpolate to get the quantile values for p: q = interp1(phat,xhat,p);