percentile.php
Table of Contents
Functions
- percentile() : string
- Return the nth percentile of the values in an array.
Functions
percentile()
Return the nth percentile of the values in an array.
percentile(mixed $numArray, int $position, string|null $method) : string
This helper wraps the ArangoDB AQL function PERCENTILE(numArray, n, method)
which returns the nth percentile of all values in the given array. The position
must be between 0 (excluded) and 100 (included).
Example AQL usage:
PERCENTILE([1, 2, 3, 4, 5], 50) // returns 3 (50th percentile)
PERCENTILE([1, 2, 3, 4, 5], 25) // returns 2 (25th percentile)
PERCENTILE([1, 2, 3, 4, 5], 75) // returns 4 (75th percentile)
PERCENTILE([1, 2, 3, 4, 5], 50, "interpolation") // returns 3 (with interpolation)
Parameters
- $numArray : mixed
-
Array expression containing numeric values (null values are ignored).
- $position : int
-
The percentile position (must be between 0 and 100).
- $method : string|null
-
Optional method: "rank" (default) or "interpolation".
Tags
Return values
string —The formatted AQL expression.