standardize
Builtin index · Statistics & ML
result = standardize(X)
Input: X · Output: result
What it is
z-score scaling of X (vector, matrix column-wise, or table per numeric column): (x - mean) / std.
Overloads
X can be Vec, Mat, or matrix.
3 forms. Each carries its own inputs, outputs and worked example — pick the tab for the one you are calling.
| Code | Input | Output | Description |
result = standardize(X) | X Vecnot documented yet | result vector | A plain Vec is standardized as a whole -- one mean, one std, across every element. |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
sv = [2.0, 4.0, 6.0, 8.0]
print("standardize on a vector: {round(standardize(sv), 3)}")
standardize on a vector: [-1.162, -0.387, 0.387, 1.162]
| Code | Input | Output | Description |
result = standardize(X) | X Matnot documented yet | result vector | An N-row, D-column Mat is standardized column by column -- each column gets its own mean and std, independent of the others. |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
sm = [1.0, 100.0; 2.0, 200.0; 3.0, 300.0]
print("standardize on a matrix, per column: {round(standardize(sm), 3)}")
standardize on a matrix, per column: [-1, -1; 0, 0; 1, 1]
| Code | Input | Output | Description |
result = standardize(X) | X matrixnot documented yet | result vector | A table is standardized per numeric column, exactly like a matrix -- a non-numeric column (a label, say) passes through untouched instead of erroring. |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
st = table(a = [1.0, 2.0, 3.0], b = [10.0, 20.0, 30.0], label = ["x", "y", "z"])
print("standardize on a table, per numeric column (label untouched):")
print(standardize(st))
standardize on a table, per numeric column (label untouched): a b label -- -- ----- -1 -1 x 0 0 y 1 1 z
normalize, robust_scale and quantile_normalize all branch the same three ways.
How it works
standardize(X) — z-score: (x - mean) / std.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.