zscore¶
-
odl.util.numerics.
zscore
(arr)[source]¶ Return arr normalized with mean 0 and unit variance.
If the input has 0 variance, the result will also have 0 variance.
- Parameters
- arrarray-like
- Returns
- zscorearray-like
Examples
Compute the z score for a small array:
>>> result = zscore([1, 0]) >>> result array([ 1., -1.]) >>> np.mean(result) 0.0 >>> np.std(result) 1.0
Does not re-scale in case the input is constant (has 0 variance):
>>> zscore([1, 1]) array([ 0., 0.])