scipy.stats.trim_mean¶
- scipy.stats.trim_mean(a, proportiontocut, axis=0)[源代码]¶
从两个尾部修剪分布后数组的返回平均值。
如果 proportiontocut =0.1,分割分数的“最左”和“最右”10%。在切片之前对输入进行排序。如果比例导致非整数切片索引(即保守切片),则切片较少 proportiontocut )。
- 参数
- aarray_like
输入数组。
- proportiontocut浮动
要截断分布的两个尾部的分数。
- axis整型或无型,可选
沿其计算修剪的平均值的轴。默认值为0。如果没有,则对整个阵列进行计算 a 。
- 退货
- trim_meanndarray
修剪数组的平均值。
示例
>>> from scipy import stats >>> x = np.arange(20) >>> stats.trim_mean(x, 0.1) 9.5 >>> x2 = x.reshape(5, 4) >>> x2 array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19]]) >>> stats.trim_mean(x2, 0.25) array([ 8., 9., 10., 11.]) >>> stats.trim_mean(x2, 0.25, axis=1) array([ 1.5, 5.5, 9.5, 13.5, 17.5])