MCPcopy Create free account
hub / github.com/numpy/numpy / anom

Method anom

numpy/ma/core.py:5361–5396  ·  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

5359 return result
5360
5361 def anom(self, axis=None, dtype=None):
5362 """
5363 Compute the anomalies (deviations from the arithmetic mean)
5364 along the given axis.
5365
5366 Returns an array of anomalies, with the same shape as the input and
5367 where the arithmetic mean is computed along the given axis.
5368
5369 Parameters
5370 ----------
5371 axis : int, optional
5372 Axis over which the anomalies are taken.
5373 The default is to use the mean of the flattened array as reference.
5374 dtype : dtype, optional
5375 Type to use in computing the variance. For arrays of integer type
5376 the default is float32; for arrays of float types it is the same as
5377 the array type.
5378
5379 See Also
5380 --------
5381 mean : Compute the mean of the array.
5382
5383 Examples
5384 --------
5385 >>> a = np.ma.array([1,2,3])
5386 >>> a.anom()
5387 masked_array(data=[-1., 0., 1.],
5388 mask=False,
5389 fill_value=1e+20)
5390
5391 """
5392 m = self.mean(axis, dtype)
5393 if not axis:
5394 return self - m
5395 else:
5396 return self - expand_dims(m, axis)
5397
5398 def var(self, axis=None, dtype=None, out=None, ddof=0,
5399 keepdims=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