为什么 Johnson-SU 分布在 scipy.stats 中不给出正偏度? [英] Why doesn't Johnson-SU distribution give positive skewness in scipy.stats?

查看:36
本文介绍了为什么 Johnson-SU 分布在 scipy.stats 中不给出正偏度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码映射了对应参数(abloc)生成的统计矩(均值、方差、偏度、超峰度)>, scale) Johnson-SU 分布 (johnsonsu).

The code below maps the statistical moments (mean, variance, skewness, excess kurtosis) generated by corresponding parameters (a, b, loc, scale) of the Johnson-SU distribution (johnsonsu).

对于我在下面的代码中指定的循环值范围,没有参数配置会导致正偏度,只有负偏度,即使应该可以将 Johnson-SU 分布参数化为正偏度.

For the range of loop values specified in my code below, no parameter configuration results in positive skewness, only negative skewness, even though it should be possible to parameterize the Johnson-SU distribution to be positively-skewed.

import numpy as np
import pandas as pd
from scipy.stats import johnsonsu

moments = ['mu','sd','sk','ku']
X = []
for a in np.arange(0.5,5,.5):
    for b in np.arange(0.5,5,.5):
        for c in np.arange(-0.5,0.5,.25): #loc
            for d in [1]: #scale
                mvsk = johnsonsu.stats(a,b,c,d,moments='mvsk')
                mvsk = [mvsk[i].tolist() for i in range(len(mvsk))]
                X.append([a,b,c,d]+mvsk)
X = pd.DataFrame(np.asarray(X), columns=['a','b','c','d']+moments)   

for m in moments:
    print(m, X[[m]].min().round(3).values[0], X[[m]].max().round(3).values[0])

打印的最小和最大时刻是:

The min and max moments printed are:

mu -29937.57 0.136
sd 0.053 48036174150.987
sk -414.36 -0.078
ku 0.221 41173.869

探索 ablocscale 参数的范围比什么更好我在下面指定了?文档只说ab 必须是正数,没有关于 locscale 必须限制的内容.

What would be better ranges to explore for the a, b, loc and scale parameters than what I have specified below? The documentation only says a and b must be positive, nothing about what loc and scale must be limited to.

推荐答案

在查看维基百科文章和源代码时,在我看来参数 a 可以改变偏度.尝试 a 的负值.文档说 a 必须大于零,但是看了一下公式和代码,这似乎是文档中的一个错误,实际上 a 可以小于小于或等于零.

On looking at the Wikipedia article and the source code, it looks to me like the parameter a can change the skewness. Try negative values of a. The documentation says a must be greater than zero, but on glancing at the formulas and the code, that appears to be a bug in the documentation, and actually a can be less than or equal to zero.

我已经尝试了你上面的程序,用 np.arange(-2.5, 2.5, .5) 替换了 a 的范围.它运行没有错误(尽管结果中存在关于不精确的警告,这些警告也存在于原始文件中)并报告:

I've tried your program above, replacing the range for a with np.arange(-2.5, 2.5, .5). It runs without error (although there are warnings about imprecision in the results, which are also present in the original) and reports:

mu -202.147 548.542
sd 0.052 16114617.207
sk -414.352 402.646
ku 0.213 41173.867

附注.我已将此报告为 Scipy 项目的错误:https://github.com/scipy/scipy/issues/13353

PS. I've reported this as a bug to the Scipy project: https://github.com/scipy/scipy/issues/13353

这篇关于为什么 Johnson-SU 分布在 scipy.stats 中不给出正偏度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆