{ } Raw JSON

bundles / scipy 1.17.1 / scipy / stats / _mstats_extras / hdquantiles

function

scipy.stats._mstats_extras:hdquantiles

source: /scipy/stats/_mstats_extras.py :28

Signature

def   hdquantiles ( data prob = (0.25, 0.5, 0.75) axis = None var = False )

Summary

Computes quantile estimates with the Harrell-Davis method.

Extended Summary

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

Parameters

data : array_like

Data array.

prob : sequence, optional

Sequence of probabilities at which to compute the quantiles.

axis : int or None, optional

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

var : bool, optional

Whether to return the variance of the estimate.

Returns

hdquantiles : MaskedArray

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.

Examples

import numpy as np
from scipy.stats.mstats import hdquantiles
data = np.array([1.2, 2.5, 3.7, 4.0, 5.1, 6.3, 7.0, 8.2, 9.4])
probabilities = [0.25, 0.5, 0.75]
quantile_estimates = hdquantiles(data, prob=probabilities)
for i, quantile in enumerate(probabilities):
    print(f"{int(quantile * 100)}th percentile: {quantile_estimates[i]}")

See also

hdquantiles_sd

Aliases

  • scipy.stats._mstats_extras.hdquantiles