Qu

robust_scale

Builtin index · Statistics & ML

result = robust_scale(X)

Input: X · Output: result

What it is

Outlier-resistant scaling of X (vector, matrix column-wise, or table per numeric column): (x - median) / IQR. Neither the median nor the interquartile range moves much when one extreme value arrives, unlike standardize's mean/std.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = robust_scale(X)
X vector or matrixnot documented yet
result —
Returns a value the same shape as X.

Examples

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

raw = [2, 4, 4, 4, 5, 5, 7, 900]
print("standardize:  {round(standardize(raw), 2)}")
print("robust_scale: {round(robust_scale(raw), 2)}")
output
standardize:  [-0.36, -0.35, -0.35, -0.35, -0.35, -0.35, -0.35, 2.47]
robust_scale: [-1.67, -0.33, -0.33, -0.33, 0.33, 0.33, 1.67, 597]

from statistics-ml

How it works

robust_scale(X) — (x - median) / IQR; resistant to outliers unlike standardize, since neither the median nor the IQR moves much when one extreme value is added.

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