quantile

Syntax

quantile(X, q, [interpolation=’linear’])

Arguments

X is a numeric vector.

q is a floating number between 0 and 1.

interpolation is a string indicating how to interpolate if the quantile is between element i and j in X with i<j. It can take the following values and the default value is ‘linear’.

  • ‘linear’: i+(j-i)*fraction where fraction is the decimal part of q*size(X).

  • ‘lower’: i

  • ‘higher’: j

  • ‘nearest’: i or j whichever is nearest.

  • ‘midpoint’: (i+ j)/2

Details

Return values at the given quantile in X.

Examples

$ a=[6, 47, 49, 15, 42, 41, 7, 39, 43, 40, 36];
$ quantile(a,0.25);
25.5

$ quantile(a,0.5);
40

$ quantile(a,0.75);
42.5

$ quantile(a,0.75, 'lower');
42

Related function: quantileSeries