scipy.stats.mstats.

hdquantiles#

scipy.stats.mstats.hdquantiles(data, prob=(0.25, 0.5, 0.75), axis=None, var=False)[source]#

Computes quantile estimates with the Harrell-Davis method.

The quantile estimates are calculated as a weighted linear combination of order statistics.

Parameters:
dataarray_like

Data array.

probsequence, optional

Sequence of probabilities at which to compute the quantiles.

axisint or None, optional

Axis along which to compute the quantiles. If None, use a flattened array.

varbool, optional

Whether to return the variance of the estimate.

Returns:
hdquantilesMaskedArray

A (p,) array of quantiles (if var is False), or a (2,p) array of quantiles and variances (if var is True), where p is the number of quantiles.

See also

hdquantiles_sd

Examples

>>> import numpy as np
>>> from scipy.stats.mstats import hdquantiles
>>>
>>> # Sample data
>>> data = np.array([1.2, 2.5, 3.7, 4.0, 5.1, 6.3, 7.0, 8.2, 9.4])
>>>
>>> # Probabilities at which to compute quantiles
>>> probabilities = [0.25, 0.5, 0.75]
>>>
>>> # Compute Harrell-Davis quantile estimates
>>> quantile_estimates = hdquantiles(data, prob=probabilities)
>>>
>>> # Display the quantile estimates
>>> for i, quantile in enumerate(probabilities):
...     print(f"{int(quantile * 100)}th percentile: {quantile_estimates[i]}")
25th percentile: 3.1505820231763066 # may vary
50th percentile: 5.194344084883956
75th percentile: 7.430626414674935