Investment Studio > Expressions > Functions > Statistical > PERCENTRANK

float percentrank(float array data, float x, integer significant_digits = 3)

Returns the rank of x in the data set, expressed as a fraction ([0, 1]). The rank is the position in data which would be occupied by x if data were sorted by size in ascending order.

All elements in data are converted to floats, with exclusion if conversion fails.

x is the value for which the rank in data is to be computed. If it doesn't match any value in data, linear interpolation between the surrounding values is used to determine its rank.

significant_digits > 0 is the number of decimals to use in the result. If omitted, it defaults to 3 (as in 0.345).

Examples

=percentrank({1, 2, 3, 4, 5}, 4)

returns 0.75: 75% of all values in the argument array are < 4; values > 4 are said to be above the 75th percentile.

=percentrank({1, 2, 3, 4, 5, 6, 7, 8, 9}, 7.4)

returns 0.8 (linear interpolation used since the value 7.4 is not in the argument array).

=percentrank({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 4, 2)

returns 0.33 (two significant digits)

See also average, count, frequency, geomean, harmean, large, max, median, min, percentile, quartile, rank, small, trimmean.