Qu

percentile

Builtin index · Core maths

result = percentile(x, p)

Input: x, p · Output: result

What it is

Same computation as quantile, with p on a 0..100 scale instead of 0..1 (p=50 is the median). x is a scalar, Vec, or Mat/Signal; p must lie in [0, 100] or the call errors.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = percentile(x, p)
x scalar, Vec, Mat, or Signalx is a scalar, Vec, or Mat/Signal.
p —p must lie in [0, 100] or the call errors.
result scalar or Num
Returns a scalar Num.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

samples = randn(1000, 1)
print("mean={mean(samples)}  std={std(samples)}  iqr={iqr(samples)}")
print("p95={percentile(samples, 95)}")
output
mean=0.012612  std=1.005695  iqr=1.356399
p95=1.671269

from core-math

How it works

percentile(x, p) — quantile with p on a 0-100 scale instead of 0-1, the more familiar spelling for the same thing.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.