Investment Studio > Expressions > Functions > Statistical > QUARTILE

float quartile(float array data, integer quartile)

Returns the specified quartile of data:

quartile Result
= 0 Smallest value in data. Equivalent to min(data).
= 1 First quartile. Equivalent to percentile(data, 25%).
= 2 Median value. Equivalent to median(data).
= 3 Third quartile. Equivalent to percentile(data, 75%).
= 4 Largest value in data. Equivalent to max(data).

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

If quartile * 0.25 is not a multiple of 1 / (N - 1), where N is the number of values in data, linear interpolation is used to determine the value at the specified quartile.

Examples

=quartile({5, 6, 7, 8, 9}, 1)

returns 6: 25% of all values in the argument array are < 6.

=quartile({1, 2, 3, 4, 5, 6, 7, 8}, 3)

returns 6.25 (linear interpolation used since 3 * 0.25 = 0.75 is not a multiple of 1 / (8 - 1)).

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