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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
A | Any | Yes | — | Input numeric, logical, complex, or gpuArray data. |
dim | NumericArray | No | — | Dimension to operate along. |
method | StringScalar | No | "zscore" | Normalization method: zscore, norm, scale, range, center, or medianiqr. |
methodtype | Any | No | — | Method subtype or explicit center/scale/range parameter. |
center_keyword | StringScalar | Yes | "center" | Literal center method selector. |
centertype | Any | Yes | — | Centering mode or explicit center values. |
scale_keyword | StringScalar | Yes | "scale" | Literal scale method selector. |
scaletype | Any | Yes | — | Scaling mode or explicit scale values. |
Returns
| Name | Type | Description |
|---|---|---|
N | NumericArray | Normalized data. |
C | NumericArray | Centering values. |
S | NumericArray | Scale values. |
Returned values from normalize depend on how many outputs the caller requests.
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:normalize:InvalidArgument | Inputs, dimension, method, method type, or name-value options are malformed. | normalize: invalid argument |
RunMat:normalize:Internal | Internal tensor conversion or allocation fails. | normalize: internal error |
How normalize works
- Supports numeric, logical, complex, and gpuArray inputs.
- The optional
dimargument 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", scaletypeforms, 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
DataVariablesandReplaceValuesforms 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.
Related Stats functions
Summary
binocdf · boxplot · cdf · cdfplot · chi2cdf · corr · corrcoef · corrcov · cov · cov2corr · dummyvar · ecdf · filloutliers · fitdist · geomean · grpstats · harmmean · icdf · isoutlier · kstest · kurtosis · lsline · mad · mode · nanmax · normcdf · norminv · normpdf · onehotdecode · onehotencode · pdf · prctile · quantile · refline · rmse · skewness · tabulate · tcdf · tiedrank · tinv · tpdf · ttest2 · wblinv
Ml
bayesopt · classify · confusionmat · crossvalind · cvpartition · fitclinear · fitctree · fitlm · kmeans · knnsearch · lasso · lassoglm · linkage · lscov · mnrfit · optimizableVariable · pdist · pdist2 · perfcurve · predict · regress · ridge · squareform · test · training · tsne
Random
binornd · bootstrp · datasample · dividerand · exprnd · gamrnd · lhsdesign · mvnrnd · normrnd · random · randsample · rng · trnd · unidrnd · unifrnd · wblrnd
Hist
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how normalize is executed, line by line, in Rust.
- View the source for normalize in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
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.