normalize

Normalizes data, by default to zero mean and unit standard deviation.

Category: Data Import and Analysis > Preprocessing Data

Syntax

N = normalize(A)

Z-score of each column (or of a vector).

N = normalize(A, 'range')

Rescales to the interval from 0 to 1.

N = normalize(A, 'center')

Subtracts the mean only.

N = normalize(A, 'norm')

Divides by the 2-norm.

Description

The default z-score subtracts the mean and divides by the standard deviation, so the result has mean 0 and standard deviation 1. This puts variables with different units on a common scale before comparing or combining them, for instance before clustering.

'range' maps the minimum to 0 and the maximum to 1, equivalent to rescale with its default limits.

Input arguments

A
Numeric vector or matrix; matrices are normalized column by column.
method
'zscore' (default), 'range', 'center', 'norm', 'scale'.

Output arguments

N
Normalized array of the same size as A.

Example

Three normalizations

x = [1 2 3 4];
normalize(x)
normalize(x, 'range')
normalize(x, 'center')
Output
ans = 1×4

   -1.1619   -0.3873    0.3873    1.1619
ans = 1×4

         0    0.3333    0.6667    1.0000
ans = 1×4

   -1.5000   -0.5000    0.5000    1.5000

See also

rescale mean std bounds