mean

Contents

mean#

class saiunit.math.mean(x, axis=None, dtype=None, keepdims=False, *, where=None, **kwargs)#

Return the mean of the array elements.

Parameters:
  • x (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Input array.

  • axis (int | Sequence[int] | None) –

    Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.

    If this is a tuple of ints, a mean is performed over multiple axes, instead of a single axis or all the axes as before.

  • dtype (str | type[Any] | dtype | SupportsDType | None) – 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) –

    If this is set to True, the axes 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.

    If the default value is passed, then keepdims will not be passed through to the mean method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.

  • where (Array | ndarray | bool | number | bool | int | float | complex | None) – Elements to include in the mean.

Returns:

out – Quantity if x is a Quantity, else an array.

Return type:

saiunit.Quantity | Array

Examples

>>> import saiunit as u
>>> a = [1.0, 2.0, 3.0] * u.second
>>> u.math.mean(a)