FUNCTION REFERENCE

zscore

Standardized z-scores.

Standardized z-scores.

Syntax

Z = zscore(X)

Syntax

Z = zscore(X, flag)

Syntax

Z = zscore(X, flag, dim)

Syntax

[Z, mu, sigma] = zscore(...)

Subtracts the mean and divides by the standard deviation along dim (default: the first dimension whose size is not 1). flag 0 or [] (default) uses the sample standard deviation (divide by n-1), flag 1 the population one (divide by n). mu and sigma are the mean and standard deviation that were used. When a standard deviation is 0 (for example constant data), Z is computed with 1 instead, so that Z is all zeros, while sigma still reports 0. NaN values are not skipped: a vector containing NaN gives NaN z-scores. Single input gives single Z, mu and sigma (computed in double, then rounded); integer input is an error, as the published page lists single and double only. Every output count follows the same rule.

Example

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

Example

[z, mu, sigma] = zscore([2 4 4 4 5 5 7 9], 1)   % mu = 5, sigma = 2

Differences from MATLAB: No 'all' or vector dimensions. 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.