FUNCTION REFERENCE

normalize

Center and scale data.

Center and scale data.

Syntax

N = normalize(A)

Syntax

N = normalize(A, dim)

Syntax

N = normalize(..., method)

Syntax

N = normalize(..., method, type)

Syntax

N = normalize(..., 'center', c, 'scale', s)

Works along dim (default: the first dimension whose size is not 1); the result is (A - C) ./ S with a center C and scale S per vector. Methods: 'zscore' (default) with type 'std' (mean and sample standard deviation, default) or 'robust' (median and median absolute deviation); 'norm' with p (default 2, Inf allowed): divide by the p-norm; 'scale' with 'std' (default), 'mad' (median absolute deviation), 'first' (the first value), 'iqr' (interquartile range, midpoint rule) or a number; 'range' with [a b] (default [0 1]): a + (A - min)./(max - min).*(b - a); 'center' with 'mean' (default), 'median' or a number; 'medianiqr': median and interquartile range. A numeric center or scale may also have one value per vector. NaN values are ignored when the center and scale are computed and stay NaN. A zero scale is not replaced, so constant data gives NaN (0/0), except 'range', which gives a for constant data. Single input gives a single result; integer input is an error (the published page lists double and single only).

Example

normalize([1 2 3])   % [-1 0 1]

Example

normalize([2 4 6], 'range', [-1 1])   % [-1 0 1]

Example

normalize([1 2 3; 4 6 8], 2, 'center', 'median')   % [-1 0 1; -2 0 2]

Differences from MATLAB: No table inputs, 'DataVariables', 'ReplaceValues' or the C and S outputs. A numeric center or scale is a scalar or one value per vector. Real 2-D data only.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.