scipy.stats.zmap(scores, compare, axis=0, ddof=0, nan_policy='propagate')[source]

Calculate the relative z-scores.

Return an array of z-scores, i.e., scores that are standardized to zero mean and unit variance, where mean and variance are calculated from the comparison array.


The input for which z-scores are calculated.


The input from which the mean and standard deviation of the normalization are taken; assumed to have the same dimension as scores.

axisint or None, optional

Axis over which mean and variance of compare are calculated. Default is 0. If None, compute over the whole array scores.

ddofint, optional

Degrees of freedom correction in the calculation of the standard deviation. Default is 0.

nan_policy{‘propagate’, ‘raise’, ‘omit’}, optional

Defines how to handle the occurrence of nans in compare. ‘propagate’ returns nan, ‘raise’ raises an exception, ‘omit’ performs the calculations ignoring nan values. Default is ‘propagate’. Note that when the value is ‘omit’, nans in scores also propagate to the output, but they do not affect the z-scores computed for the non-nan values.


Z-scores, in the same shape as scores.


This function preserves ndarray subclasses, and works also with matrices and masked arrays (it uses asanyarray instead of asarray for parameters).


>>> from scipy.stats import zmap
>>> a = [0.5, 2.0, 2.5, 3]
>>> b = [0, 1, 2, 3, 4]
>>> zmap(a, b)
array([-1.06066017,  0.        ,  0.35355339,  0.70710678])