LoginSignup
0
0

More than 1 year has passed since last update.

scipy.stats: 平均値まわりの第 r 次母積率 moment

Last updated at Posted at 2022-05-26

平均値まわりの r 次母積率

$(x-\mu)^r$ の期待値のことである。$\nu_r'$ で表すことが多い。

離散変数のときは

$\nu_r' = \sum(x-\mu)^r f(x)$

連続変数のときは

$\nu_r' = \displaystyle \int_{-\infty}^{\infty} (x-\mu)^rf(x)dx$

moment(a, moment=1, axis=0, nan_policy='propagate')

from scipy.stats import moment
x = [1.2, 3.1, 4.6, 2.2, 5.7]

1次(デフォルト),2次,3次,4次の母積率(モーメント)

moment(x), moment(x, 2), moment(x, 3), moment(x, 4)
(0.0, 2.6184, 0.6126720000000052, 11.18588832)
moment(x, [0, 1, 2, 3, 4, 5])
array([ 1.        ,  0.        ,  2.6184    ,  0.612672  , 11.18588832,
        4.79398679])

$\nu_2'$ は母分散(ddof=0)である。

x = [1.2, 3.1, 4.6, 2.2, 5.7]
moment(x, 2), np.var(x)

(2.6184, 2.6184)

利用例

尖度 $g_2$ は 以下のように定義される。

$g_2 = m_4\ /\ m_2^2 - 3$

from scipy.stats import kurtosis
x = [1.2, 3.1, 4.6, 2.2, 5.7]

m4 = moment(x, 4)
m2 = moment(x, 2)
g2 = m4 / m2**2 - 3 # kurtosis(x)
g2, kurtosis(x)
(-1.3684571122281206, -1.3684571122281206)

歪度 $g_1$ は以下のように定義される。

$g_1 = m_3\ /\ m_2^{3/2}$

from scipy.stats import skew
x = [1.2, 3.1, 4.6, 2.2, 5.7]

m3 = moment(x, 3)
m2 = moment(x, 2)
g1 = m3 / m2**(3/2) # skew(x)
g1, skew(x)
(0.14460191499270095, 0.14460191499270095)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0