zscore

odl.core.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

arr : array-like

Returns

zscore : array-like

Examples

Compute the z score for a small array:

>>> result = zscore(odl.vector([1.0, 0.0]))
>>> result
rn(2).element([ 1., -1.])
>>> odl.mean(result)
0.0
>>> odl.std(result)
1.0

Does not re-scale in case the input is constant (has 0 variance):

>>> zscore(odl.vector([1.0, 1.0]))
rn(2).element([ 0., 0.])