statsmodels.stats.stattools.medcouple#

statsmodels.stats.stattools.medcouple(y, axis=0, use_fast=True)[source]#

Calculate the medcouple robust measure of skew

Parameters:
yarray_like

Data to compute use in the estimator.

axisint or None, optional

Axis along which the medcouple statistic is computed. If None, the entire array is used.

use_fastbool, optional

Whether to use the faster O(N log N) implementation. Default is True. To use the legacy O(N**2) version, set to False.

Returns:
mcfloat or ndarray

The medcouple statistic.

Notes

The legacy algorithm (use_fast=False) uses an O(N**2) implementation which provides exact results and is reliable for all dataset sizes, including small inputs and cases with ties. However, it requires a O(N**2) memory allocations, and so may not work for very large arrays (N>10000).

The fast algorithm (use_fast=True) implements an O(N log N) approximation which is optimized for large datasets. It is not intended for small sample sizes (N < 10) or datasets with a high proportion of ties, as it may yield numerically unstable or inaccurate results in these cases. For such inputs, prefer use_fast=False to ensure correctness.

If NaNs are present in the input when use_fast=True, the result will be NaN. To preserve legacy behavior, a number may be returned when use_fast=False.

If the size of y is less than 3 and use_fast=True, the result will be NaN. To preserve legacy behavior, a value may be returned when use_fast=False.

Small numerical differences are possible based on the choice of algorithm.

References