当前位置: 首页>>代码示例>>Python>>正文


Python stats.kurtosistest方法代码示例

本文整理汇总了Python中scipy.stats.kurtosistest方法的典型用法代码示例。如果您正苦于以下问题:Python stats.kurtosistest方法的具体用法?Python stats.kurtosistest怎么用?Python stats.kurtosistest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.stats的用法示例。


在下文中一共展示了stats.kurtosistest方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_omni_normtest

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosistest [as 别名]
def test_omni_normtest():
    #tests against R fBasics
    from scipy import stats

    st_pv_R = np.array(
              [[3.994138321207883, -1.129304302161460,  1.648881473704978],
               [0.1357325110375005, 0.2587694866795507, 0.0991719192710234]])

    nt = omni_normtest(x)
    assert_almost_equal(nt, st_pv_R[:, 0], 14)

    st = stats.skewtest(x)
    assert_almost_equal(st, st_pv_R[:, 1], 14)

    kt = stats.kurtosistest(x)
    assert_almost_equal(kt, st_pv_R[:, 2], 11)

    st_pv_R = np.array(
              [[34.523210399523926,  4.429509162503833,  3.860396220444025],
               [3.186985686465249e-08, 9.444780064482572e-06, 1.132033129378485e-04]])

    x2 = x**2
    #TODO: fix precision in these test with relative tolerance
    nt = omni_normtest(x2)
    assert_almost_equal(nt, st_pv_R[:, 0], 12)

    st = stats.skewtest(x2)
    assert_almost_equal(st, st_pv_R[:, 1], 12)

    kt = stats.kurtosistest(x2)
    assert_almost_equal(kt, st_pv_R[:, 2], 12) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:33,代码来源:test_statstools.py

示例2: test_normalitytests

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosistest [as 别名]
def test_normalitytests():
    # numbers verified with R: dagoTest in package fBasics
    st_normal, st_skew, st_kurt = (3.92371918, 1.98078826, -0.01403734)
    pv_normal, pv_skew, pv_kurt = (0.14059673, 0.04761502, 0.98880019)
    x = np.array((-2,-1,0,1,2,3)*4)**2
    yield assert_array_almost_equal, stats.normaltest(x), (st_normal, pv_normal)
    yield assert_array_almost_equal, stats.skewtest(x), (st_skew, pv_skew)
    yield assert_array_almost_equal, stats.kurtosistest(x), (st_kurt, pv_kurt) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:test_stats.py

示例3: test_kurtosistest_too_few_samples

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosistest [as 别名]
def test_kurtosistest_too_few_samples():
    # Regression test for ticket #1425.
    # kurtosistest requires at least 5 samples; 4 should raise a ValueError.
    x = np.arange(4.0)
    assert_raises(ValueError, stats.kurtosistest, x) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_stats.py

示例4: test_vs_nonmasked

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosistest [as 别名]
def test_vs_nonmasked(self):
        x = np.array((-2,-1,0,1,2,3)*4)**2
        assert_array_almost_equal(mstats.normaltest(x),
                                  stats.normaltest(x))
        assert_array_almost_equal(mstats.skewtest(x),
                                  stats.skewtest(x))
        assert_array_almost_equal(mstats.kurtosistest(x),
                                  stats.kurtosistest(x))

        funcs = [stats.normaltest, stats.skewtest, stats.kurtosistest]
        mfuncs = [mstats.normaltest, mstats.skewtest, mstats.kurtosistest]
        x = [1, 2, 3, 4]
        for func, mfunc in zip(funcs, mfuncs):
            assert_raises(ValueError, func, x)
            assert_raises(ValueError, mfunc, x) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:17,代码来源:test_mstats_basic.py

示例5: test_axis_None

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosistest [as 别名]
def test_axis_None(self):
        # Test axis=None (equal to axis=0 for 1-D input)
        x = np.array((-2,-1,0,1,2,3)*4)**2
        assert_allclose(mstats.normaltest(x, axis=None), mstats.normaltest(x))
        assert_allclose(mstats.skewtest(x, axis=None), mstats.skewtest(x))
        assert_allclose(mstats.kurtosistest(x, axis=None),
                        mstats.kurtosistest(x)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:9,代码来源:test_mstats_basic.py

示例6: test_maskedarray_input

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosistest [as 别名]
def test_maskedarray_input(self):
        # Add some masked values, test result doesn't change
        x = np.array((-2,-1,0,1,2,3)*4)**2
        xm = np.ma.array(np.r_[np.inf, x, 10],
                         mask=np.r_[True, [False] * x.size, True])
        assert_allclose(mstats.normaltest(xm), stats.normaltest(x))
        assert_allclose(mstats.skewtest(xm), stats.skewtest(x))
        assert_allclose(mstats.kurtosistest(xm), stats.kurtosistest(x)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:10,代码来源:test_mstats_basic.py

示例7: test_nd_input

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosistest [as 别名]
def test_nd_input(self):
        x = np.array((-2,-1,0,1,2,3)*4)**2
        x_2d = np.vstack([x] * 2).T
        for func in [mstats.normaltest, mstats.skewtest, mstats.kurtosistest]:
            res_1d = func(x)
            res_2d = func(x_2d)
            assert_allclose(res_2d[0], [res_1d[0]] * 2)
            assert_allclose(res_2d[1], [res_1d[1]] * 2) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:10,代码来源:test_mstats_basic.py

示例8: test_kurtosistest_result_attributes

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosistest [as 别名]
def test_kurtosistest_result_attributes(self):
        x = np.array((-2, -1, 0, 1, 2, 3)*4)**2
        res = mstats.kurtosistest(x)
        attributes = ('statistic', 'pvalue')
        check_named_results(res, attributes, ma=True) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:7,代码来源:test_mstats_basic.py

示例9: test_normalitytests

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosistest [as 别名]
def test_normalitytests():
    assert_raises(ValueError, stats.skewtest, 4.)
    assert_raises(ValueError, stats.kurtosistest, 4.)
    assert_raises(ValueError, stats.normaltest, 4.)

    # numbers verified with R: dagoTest in package fBasics
    st_normal, st_skew, st_kurt = (3.92371918, 1.98078826, -0.01403734)
    pv_normal, pv_skew, pv_kurt = (0.14059673, 0.04761502, 0.98880019)
    x = np.array((-2,-1,0,1,2,3)*4)**2
    attributes = ('statistic', 'pvalue')

    assert_array_almost_equal(stats.normaltest(x), (st_normal, pv_normal))
    check_named_results(stats.normaltest(x), attributes)
    assert_array_almost_equal(stats.skewtest(x), (st_skew, pv_skew))
    check_named_results(stats.skewtest(x), attributes)
    assert_array_almost_equal(stats.kurtosistest(x), (st_kurt, pv_kurt))
    check_named_results(stats.kurtosistest(x), attributes)

    # Test axis=None (equal to axis=0 for 1-D input)
    assert_array_almost_equal(stats.normaltest(x, axis=None),
           (st_normal, pv_normal))
    assert_array_almost_equal(stats.skewtest(x, axis=None),
           (st_skew, pv_skew))
    assert_array_almost_equal(stats.kurtosistest(x, axis=None),
           (st_kurt, pv_kurt))

    x = np.arange(10.)
    x[9] = np.nan
    with np.errstate(invalid="ignore"):
        assert_array_equal(stats.skewtest(x), (np.nan, np.nan))

    expected = (1.0184643553962129, 0.30845733195153502)
    assert_array_almost_equal(stats.skewtest(x, nan_policy='omit'), expected)

    with np.errstate(all='ignore'):
        assert_raises(ValueError, stats.skewtest, x, nan_policy='raise')
    assert_raises(ValueError, stats.skewtest, x, nan_policy='foobar')

    x = np.arange(30.)
    x[29] = np.nan
    with np.errstate(all='ignore'):
        assert_array_equal(stats.kurtosistest(x), (np.nan, np.nan))

    expected = (-2.2683547379505273, 0.023307594135872967)
    assert_array_almost_equal(stats.kurtosistest(x, nan_policy='omit'),
                              expected)

    assert_raises(ValueError, stats.kurtosistest, x, nan_policy='raise')
    assert_raises(ValueError, stats.kurtosistest, x, nan_policy='foobar')

    with np.errstate(all='ignore'):
        assert_array_equal(stats.normaltest(x), (np.nan, np.nan))

    expected = (6.2260409514287449, 0.04446644248650191)
    assert_array_almost_equal(stats.normaltest(x, nan_policy='omit'), expected)

    assert_raises(ValueError, stats.normaltest, x, nan_policy='raise')
    assert_raises(ValueError, stats.normaltest, x, nan_policy='foobar') 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:60,代码来源:test_stats.py

示例10: normality_stats

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosistest [as 别名]
def normality_stats(arr):
    """
    统计信息偏度,峰度,正态分布检测,p-value
        eg:
                input:

                2014-07-25    223.57
                2014-07-28    224.82
                2014-07-29    225.01
                               ...
                2016-07-22    222.27
                2016-07-25    230.01
                2016-07-26    225.93

                output:

                array skew = -0.282635248604699
                array skew p-value = 0.009884539532576725
                array kurt = 0.009313464006726946
                array kurt p-value = 0.8403947352953821
                array norm = NormaltestResult(statistic=6.6961445106692237, pvalue=0.035152053009441256)
                array norm p-value = 0.035152053009441256

                input:

                            tsla	bidu	noah	sfun	goog	vips	aapl
                2014-07-25	223.57	226.50	15.32	12.110	589.02	21.349	97.67
                2014-07-28	224.82	225.80	16.13	12.450	590.60	21.548	99.02
                2014-07-29	225.01	220.00	16.75	12.220	585.61	21.190	98.38
                ...	...	...	...	...	...	...	...
                2016-07-22	222.27	160.88	25.50	4.850	742.74	13.510	98.66
                2016-07-25	230.01	160.25	25.57	4.790	739.77	13.390	97.34
                2016-07-26	225.93	163.09	24.75	4.945	740.92	13.655	97.76

                output:

                array skew = [-0.2826 -0.2544  0.1456  1.0322  0.2095  0.095   0.1719]
                array skew p-value = [ 0.0099  0.0198  0.1779  0.      0.0539  0.3781  0.1124]
                array kurt = [ 0.0093 -0.8414 -0.4205  0.4802 -1.547  -0.9203 -1.2104]
                array kurt p-value = [ 0.8404  0.      0.0201  0.0461  1.      0.      0.    ]
                array norm = NormaltestResult(statistic=array([   6.6961,   52.85  ,    7.2163,   69.0119,    3.7161,
                69.3468, 347.229 ]), pvalue=array([ 0.0352,  0.    ,  0.0271,  0.    ,  0.156 ,  0.    ,  0.    ]))
                array norm p-value = [ 0.0352  0.      0.0271  0.      0.156   0.      0.    ]

    :param arr: pd.DataFrame or pd.Series or Iterable
    """
    log_func = logging.info if ABuEnv.g_is_ipython else print

    log_func('array skew = {}'.format(scs.skew(arr)))
    log_func('array skew p-value = {}'.format(scs.skewtest(arr)[1]))

    log_func('array kurt = {}'.format(scs.kurtosis(arr)))
    log_func('array kurt p-value = {}'.format(scs.kurtosistest(arr)[1]))

    log_func('array norm = {}'.format(scs.normaltest(arr)))
    log_func('array norm p-value = {}'.format(scs.normaltest(arr)[1])) 
开发者ID:bbfamily,项目名称:abu,代码行数:58,代码来源:ABuStatsUtil.py


注:本文中的scipy.stats.kurtosistest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。