spectrochempy.mean
- mean(dataset, dim=None, dtype=None, keepdims=False)[source]
Compute the arithmetic mean along the specified axis.
Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis.
- Parameters:
dataset (array_like) – Array containing numbers whose mean is desired.
dim (None or int or dimension name, optional) – Dimension or dimensions along which to operate.
dtype (data-type, optional) – Type to use in computing the mean. For integer inputs, the default is
float64
; for floating point inputs, it is the same as the input dtype.keepdims (bool, optional) – If this is set to True, the dimensions which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
- Returns:
mean – A new array containing the mean values.
See also
Notes
The arithmetic mean is the sum of the elements along the axis divided by the number of elements.
Examples
>>> nd = scp.read('irdata/nh4y-activation.spg') >>> nd NDDataset: [float64] a.u. (shape: (y:55, x:5549)) >>> scp.mean(nd) <Quantity(1.25085858, 'absorbance')> >>> scp.mean(nd, keepdims=True) NDDataset: [float64] a.u. (shape: (y:1, x:1)) >>> m = scp.mean(nd, dim='y') >>> m NDDataset: [float64] a.u. (size: 5549) >>> m.x Coord: [float64] cm⁻¹ (size: 5549)