MCPcopy
hub / github.com/numpy/numpy / anom

Method anom

numpy/ma/core.py:5432–5468  ·  view source on GitHub ↗

Compute the anomalies (deviations from the arithmetic mean) along the given axis. Returns an array of anomalies, with the same shape as the input and where the arithmetic mean is computed along the given axis. Parameters ---------- axis : in

(self, axis=None, dtype=None)

Source from the content-addressed store, hash-verified

5430 return result
5431
5432 def anom(self, axis=None, dtype=None):
5433 """
5434 Compute the anomalies (deviations from the arithmetic mean)
5435 along the given axis.
5436
5437 Returns an array of anomalies, with the same shape as the input and
5438 where the arithmetic mean is computed along the given axis.
5439
5440 Parameters
5441 ----------
5442 axis : int, optional
5443 Axis over which the anomalies are taken.
5444 The default is to use the mean of the flattened array as reference.
5445 dtype : dtype, optional
5446 Type to use in computing the variance. For arrays of integer type
5447 the default is float32; for arrays of float types it is the same as
5448 the array type.
5449
5450 See Also
5451 --------
5452 mean : Compute the mean of the array.
5453
5454 Examples
5455 --------
5456 >>> import numpy as np
5457 >>> a = np.ma.array([1,2,3])
5458 >>> a.anom()
5459 masked_array(data=[-1., 0., 1.],
5460 mask=False,
5461 fill_value=1e+20)
5462
5463 """
5464 m = self.mean(axis, dtype)
5465 if not axis:
5466 return self - m
5467 else:
5468 return self - expand_dims(m, axis)
5469
5470 def var(self, axis=None, dtype=None, out=None, ddof=0,
5471 keepdims=np._NoValue, mean=np._NoValue):

Callers 4

test_meananom_objectMethod · 0.80
test_anom_shapeMethod · 0.80
test_anomMethod · 0.80
test_on_ndarrayMethod · 0.80

Calls 2

meanMethod · 0.95
expand_dimsFunction · 0.90

Tested by 4

test_meananom_objectMethod · 0.64
test_anom_shapeMethod · 0.64
test_anomMethod · 0.64
test_on_ndarrayMethod · 0.64