scipy.stats.mstats.

count_tied_groups#

scipy.stats.mstats.count_tied_groups(x, use_missing=False)[source]#

計算相等值的數量。

參數:
x序列

用於計算相等值的資料序列

use_missing布林值, 選用

是否將遺失值視為相等值。

回傳:
count_tied_groups字典

回傳一個字典 (相等值數量:群組數量)。

範例

>>> from scipy.stats import mstats
>>> import numpy as np
>>> z = [0, 0, 0, 2, 2, 2, 3, 3, 4, 5, 6]
>>> mstats.count_tied_groups(z)
{2: 1, 3: 2}

在上述範例中,相等值為 0 (3 次)、2 (3 次) 和 3 (2 次)。

>>> z = np.ma.array([0, 0, 1, 2, 2, 2, 3, 3, 4, 5, 6])
>>> mstats.count_tied_groups(z)
{2: 2, 3: 1}
>>> z[[1,-1]] = np.ma.masked
>>> mstats.count_tied_groups(z, use_missing=True)
{2: 2, 3: 1}