Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Percentiles of a data set

`Y = prctile(X,p)`

`Y = prctile(X,p,dim)`

returns
percentiles of the values in a data vector or matrix `Y`

= prctile(`X`

,`p`

)`X`

for
the percentages `p`

in the interval [0,100].

If

`X`

is a vector, then`Y`

is a scalar or a vector with the same length as the number of percentiles required (`length(p)`

).`Y(i)`

contains the`p(i)`

percentile.If

`X`

is a matrix, then`Y`

is a row vector or a matrix, where the number of rows of`Y`

is equal to the number of percentiles required (`length(p)`

). The`i`

th row of`Y`

contains the`p(i)`

percentiles of each column of`X`

.For multidimensional arrays,

`prctile`

operates along the first nonsingleton dimension of`X`

.

For an *n*-element vector `X`

, `prctile`

returns
percentiles as follows:

The sorted values in

`X`

are taken as the 100(0.5/*n*)th, 100(1.5/*n*)th, ..., 100([*n*– 0.5]/*n*)th percentiles. For example:For a data vector of five elements such as {6, 3, 2, 10, 1}, the sorted elements {1, 2, 3, 6, 10} respectively correspond to the 10th, 30th, 50th, 70th, and 90th percentiles.

For a data vector of six elements such as {6, 3, 2, 10, 8, 1}, the sorted elements {1, 2, 3, 6, 8, 10} respectively correspond to the (50/6)th, (150/6)th, (250/6)th, (350/6)th, (450/6)th, and (550/6)th percentiles.

`prctile`

uses linear interpolation to compute percentiles for percentages between 100(0.5/*n*) and 100([*n*– 0.5]/*n*).`prctile`

assigns the minimum or maximum values in`X`

to the percentiles corresponding to the percentages outside that range.

`prctile`

treats `NaN`

s
as missing values and removes them.

[1] Langford, E. “Quartiles in Elementary Statistics”, *Journal
of Statistics Education*. Vol. 14, No. 3, 2006.

Was this topic helpful?