Qu

quantile

Builtin index · Core maths

result = quantile(x, q, [on_invalid=])

Input: x, q, on_invalid · Output: result

What it is

Linear-interpolation quantile (NumPy's default interpolation="linear" method). x is a scalar, Vec, or Mat/Signal (flattened); q is a scalar rank in [0, 1] (0.5 is the median), interpolated between the two nearest order statistics when it doesn't land exactly on one. on_invalid= ("propagate"/"ignore"/"error", see this section's intro) controls NaN/Inf handling. On a Mat, the optional axis= keyword (0 or 1) reduces along just that dimension instead of flattening.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = quantile(x, q, [on_invalid=])
x scalar, Vec, Mat, or Signalx is a scalar, Vec, or Mat/Signal (flattened).
q scalarq is a scalar rank in [0, 1] (0.5 is the median), interpolated between the two nearest order statistics when it doesn't land exactly on one.
on_invalid optionalon_invalid= ("propagate"/"ignore"/"error", see this section's intro) controls NaN/Inf handling.
result scalar, Num, or Vec
Returns a scalar Num with no axis=, or a length-cols/rows Vec with one.

Examples

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

q1 = quantile(y, 0.25)
q3 = quantile(y, 0.75)
print("median = {median(y)}, IQR = {q3 - q1}")
output
median = 3.5, IQR = 6.75

from fundamentals