median

Contents

median#

class saiunit.math.median(x, axis=None, overwrite_input=False, keepdims=False, **kwargs)#

Return the median 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 medians are computed. The default is to compute the median along a flattened version of the array. A sequence of axes is supported since version 1.9.0.

  • overwrite_input (bool) – If True, then allow use of memory of input array a for calculations. The input array will be modified by the call to median. This will save memory when you do not need to preserve the contents of the input array. Treat the input as undefined, but it will probably be fully or partially sorted. Default is False. If overwrite_input is True and a is not already an ndarray, an error will be raised.

  • 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 original arr.

Returns:

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

Return type:

saiunit.Quantity | Array

Examples

>>> import saiunit as u
>>> a = [1, 2, 3, 4, 5] * u.second
>>> u.math.median(a)