在matlab
图像处理应用中,经常会用到quantile函数,这个函数的作用是求数列或矩阵的分位数。
在程序中给的文档说明如下:
语法
Y = quantile(X,p)
Y =
quantile(X,p,dim)
Y = quantile(X,N,...)
描述 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.
Y = quantile(X,N,...) returns quantiles at the N
evenly-spaced cumulative probabilities (1:N)/(N+1). N is a scalar
positive integer value.
举例:
x[1 1 2 3 4 5 5 8 10]
数组中有9个元素,
n=9 p=0.6
y=quantile(x,p);
也可以写成y=quantile(a(:),[.6]);
得到:y=4.9