quantile

Contents

quantile#

class brainunit.math.quantile(a, q, axis=None, method='linear', keepdims=False, **kwargs)#

Compute the q-th percentile of the data along the specified axis.

Returns the q-th percentile(s) of the array elements.

Parameters:
  • a (Array | saiunit.Quantity) – Input array or Quantity.

  • q (Array | ndarray | bool | number | bool | int | float | complex) – Percentile or sequence of percentiles to compute, which must be between 0 and 100 inclusive.

  • method (str) –

    This parameter specifies the method to use for estimating the percentile. There are many different methods, some unique to NumPy. See the notes for explanation. The options sorted by their R type as summarized in the H&F paper (Hyndman & Fan, 1996) are:

    1. ’inverted_cdf’

    2. ’averaged_inverted_cdf’

    3. ’closest_observation’

    4. ’interpolated_inverted_cdf’

    5. ’hazen’

    6. ’weibull’

    7. ’linear’ (default)

    8. ’median_unbiased’

    9. ’normal_unbiased’

    The first three methods are discontinuous. NumPy further defines the following discontinuous variations of the default ‘linear’ (7.) option:

    • ’lower’

    • ’higher’,

    • ’midpoint’

    • ’nearest’

  • keepdims (bool | None) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.

Returns:

out – Output array.

Return type:

Array

Examples

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