本文簡要介紹 python 語言中 scipy.stats.trimboth
的用法。
用法:
scipy.stats.trimboth(a, proportiontocut, axis=0)#
從數組的兩端切掉一部分項目。
從傳遞數組的兩端切掉傳遞的項目比例(即,在 ratiotocut = 0.1 的情況下,分割最左邊的 10% 和最右邊的 10% 分數)。修剪的值是最低和最高的。如果比例導致非整數切片索引(即保守地切掉比例切),則切掉更少。
- a: array_like
要修剪的數據。
- proportiontocut: 浮點數
修剪每一端的總數據集的比例(範圍 0-1)。
- axis: int 或無,可選
沿其修剪數據的軸。默認值為 0。如果沒有,則計算整個數組 a。
- out: ndarray
數組 a 的修剪版本。修剪內容的順序未定義。
參數 ::
返回 ::
例子:
創建一個包含 10 個值的數組,並從每一端修剪 10% 的值:
>>> import numpy as np >>> from scipy import stats >>> a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> stats.trimboth(a, 0.1) array([1, 3, 2, 4, 5, 6, 7, 8])
請注意,輸入數組的元素是按值修剪的,但輸出數組不一定是排序的。
修剪的比例向下舍入到最接近的整數。例如,從 10 個值的數組的每一端修剪 25% 的值將返回一個 6 個值的數組:
>>> b = np.arange(10) >>> stats.trimboth(b, 1/4).shape (6,)
多維數組可以沿任何軸或整個數組修剪:
>>> c = [2, 4, 6, 8, 0, 1, 3, 5, 7, 9] >>> d = np.array([a, b, c]) >>> stats.trimboth(d, 0.4, axis=0).shape (1, 10) >>> stats.trimboth(d, 0.4, axis=1).shape (3, 2) >>> stats.trimboth(d, 0.4, axis=None).shape (6,)
相關用法
- Python SciPy stats.trim_mean用法及代碼示例
- Python SciPy stats.trim1用法及代碼示例
- Python SciPy stats.triang用法及代碼示例
- Python SciPy stats.truncpareto用法及代碼示例
- Python SciPy stats.truncweibull_min用法及代碼示例
- Python SciPy stats.truncexpon用法及代碼示例
- Python SciPy stats.truncnorm用法及代碼示例
- Python SciPy stats.trapezoid用法及代碼示例
- Python SciPy stats.theilslopes用法及代碼示例
- Python SciPy stats.t用法及代碼示例
- Python SciPy stats.ttest_rel用法及代碼示例
- Python SciPy stats.tvar用法及代碼示例
- Python SciPy stats.tsem用法及代碼示例
- Python SciPy stats.ttest_ind_from_stats用法及代碼示例
- Python SciPy stats.ttest_1samp用法及代碼示例
- Python SciPy stats.ttest_ind用法及代碼示例
- Python SciPy stats.tmean用法及代碼示例
- Python SciPy stats.tmin用法及代碼示例
- Python SciPy stats.tmax用法及代碼示例
- Python SciPy stats.tukeylambda用法及代碼示例
- Python SciPy stats.tstd用法及代碼示例
- Python SciPy stats.tiecorrect用法及代碼示例
- Python SciPy stats.tukey_hsd用法及代碼示例
- Python SciPy stats.anderson用法及代碼示例
- Python SciPy stats.iqr用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.stats.trimboth。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。