quantile - Quantiles

Syntax

Y = quantile(X,p)
Y = quantile(X,p,dim)

Description

Y = quantile(X,p) returns quantiles of the values in X. p is a scalar or a vector of cumulative probability values. When X is a vector, Y is the same size as p, and Y(i) contains the p(i)th quantile. When X is a matrix, the ith row of Y contains the p(i)th quantiles of each column of X. For N-dimensional arrays, quantile operates along the first nonsingleton dimension of X.

Y = quantile(X,p,dim) calculates quantiles along dimension dim. The dimth dimension of Y has length length(P).

Quantiles are specified using cumulative probabilities from 0 to 1. For an n-element vector X, quantile computes quantiles as follows:

  1. The sorted values in X are taken as the (0.5/n), (1.5/n), ..., ([n-0.5]/n) quantiles.

  2. Linear interpolation is used to compute quantiles for probabilities between (0.5/n) and ([n-0.5]/n).

  3. The minimum or maximum values in X are assigned to quantiles for probabilities outside that range.

quantile treats NaNs as missing values and removes them.

Examples

y = quantile(x,.50); % the median of x
y = quantile(x,[.025 .25 .50 .75 .975]); % Summary of x

See Also

prctile, iqr, median

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS