statsmodels.stats.robust_compare.trimboth(a, proportiontocut, axis=0)[source]

Slices off a proportion of items from both ends of an array.

Slices off the passed proportion of items from both ends of the passed array (i.e., with proportiontocut = 0.1, slices leftmost 10% and rightmost 10% of scores). You must pre-sort the array if you want ‘proper’ trimming. Slices off less if proportion results in a non-integer slice index (i.e., conservatively slices off proportiontocut).


Data to trim.

proportiontocutfloat or int

Proportion of data to trim at each end.

axisint or None

Axis along which the observations are trimmed. The default is to trim along axis=0. If axis is None then the array will be flattened before trimming.


Trimmed version of array a.


>>> from scipy import stats
>>> a = np.arange(20)
>>> b = stats.trimboth(a, 0.1)
>>> b.shape

Last update: May 25, 2024