normalize — Normalize data by centering and scaling along a dimension.

normalize(A) returns z-scores of A along the first non-singleton dimension.

Syntax

N = normalize(A)
N = normalize(A, dim)
N = normalize(A, method)
N = normalize(A, dim, method)
N = normalize(A, method, methodtype)
N = normalize(A, dim, method, methodtype)
All supported normalize forms
N = normalize(A)
N = normalize(A, dim)
N = normalize(A, method)
N = normalize(A, dim, method)
N = normalize(A, method, methodtype)
N = normalize(A, dim, method, methodtype)
N = normalize(A, "center", centertype, "scale", scaletype)
N = normalize(A, dim, "center", centertype, "scale", scaletype)
[N, C, S] = normalize(___)

Inputs

NameTypeRequiredDefaultDescription
AAnyYesInput numeric, logical, complex, or gpuArray data.
dimNumericArrayNoDimension to operate along.
methodStringScalarNo"zscore"Normalization method: zscore, norm, scale, range, center, or medianiqr.
methodtypeAnyNoMethod subtype or explicit center/scale/range parameter.
center_keywordStringScalarYes"center"Literal center method selector.
centertypeAnyYesCentering mode or explicit center values.
scale_keywordStringScalarYes"scale"Literal scale method selector.
scaletypeAnyYesScaling mode or explicit scale values.

Returns

NameTypeDescription
NNumericArrayNormalized data.
CNumericArrayCentering values.
SNumericArrayScale values.

Returned values from normalize depend on how many outputs the caller requests.

Errors

IdentifierWhenMessage
RunMat:normalize:InvalidArgumentInputs, dimension, method, method type, or name-value options are malformed.normalize: invalid argument
RunMat:normalize:InternalInternal tensor conversion or allocation fails.normalize: internal error

How normalize works

  • Supports numeric, logical, complex, and gpuArray inputs.
  • The optional dim argument chooses the operating dimension.
  • Default z-score normalization subtracts the mean and divides by sample standard deviation, omitting NaN values while preserving NaNs in the output.
  • Supports "zscore", "zscore","robust", "norm", "norm",p, "scale", "range", "center", and "medianiqr" methods.
  • Supports combined "center", centertype, "scale", scaletype forms, including explicit numeric center and scale arrays compatible by implicit expansion.
  • [N,C,S] = normalize(...) returns normalized values plus the center and scale parameters so they can be reused on another array.
  • Table and timetable DataVariables and ReplaceValues forms are tracked with the broader tabular workflow work.

Examples

Default z-score normalization

N = normalize([1; 2; 3])

Expected output:

N = [-1; 0; 1]

Normalize by Euclidean norm

N = normalize([3; 4], "norm")

Expected output:

N = [0.6; 0.8]

Using normalize with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how normalize changes the result.

Run a small normalize example, explain the result, then change one input and compare the output.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how normalize is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.