This module provides combination of statistics as single operation.
For now it provides min/max (and optionally positive min) and indices of first occurences (i.e., argmin/argmax) in a single pass.
Returns min, max and optionally strictly positive min of data.
It also computes the indices of first occurence of min/max.
NaNs are ignored while computing min/max unless all data is NaNs, in which case returned min/max are NaNs.
Examples:
>>> import numpy
>>> data = numpy.arange(10)
Usage as a function returning min and max:
>>> min_, max_ = min_max(data)
Usage as a function returning a result object to access all information:
>>> result = min_max(data) # Do not get positive min
>>> result.minimum, result.argmin
0, 0
>>> result.maximum, result.argmax
9, 10
>>> result.min_positive, result.argmin_positive # Not computed
None, None
Getting strictly positive min information:
>>> result = min_max(data, min_positive=True)
>>> result.min_positive, result.argmin_positive # Computed
1, 1
Parameters: |
|
---|---|
Returns: | An object with minimum, maximum and min_positive attributes and the indices of first occurence in the flattened data: argmin, argmax and argmin_positive attributes. If all data is <= 0 or min_positive argument is False, then min_positive and argmin_positive are None. |
Raises: | ValueError if data is empty |