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


Python stats.kurtosis方法代码示例

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


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

示例1: test_kurt

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def test_kurt(self, float_frame_with_na, float_frame, float_string_frame):
        from scipy.stats import kurtosis

        def alt(x):
            if len(x) < 4:
                return np.nan
            return kurtosis(x, bias=False)

        assert_stat_op_calc('kurt', alt, float_frame_with_na)
        assert_stat_op_api('kurt', float_frame, float_string_frame)

        index = MultiIndex(levels=[['bar'], ['one', 'two', 'three'], [0, 1]],
                           codes=[[0, 0, 0, 0, 0, 0],
                                  [0, 1, 2, 0, 1, 2],
                                  [0, 1, 0, 1, 0, 1]])
        df = DataFrame(np.random.randn(6, 3), index=index)

        kurt = df.kurt()
        kurt2 = df.kurt(level=0).xs('bar')
        tm.assert_series_equal(kurt, kurt2, check_names=False)
        assert kurt.name is None
        assert kurt2.name == 'bar' 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:24,代码来源:test_analytics.py

示例2: columns

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def columns():
    feature_sizes = dict(chroma_stft=12, chroma_cqt=12, chroma_cens=12,
                         tonnetz=6, mfcc=20, rmse=1, zcr=1,
                         spectral_centroid=1, spectral_bandwidth=1,
                         spectral_contrast=7, spectral_rolloff=1)
    moments = ('mean', 'std', 'skew', 'kurtosis', 'median', 'min', 'max')

    columns = []
    for name, size in feature_sizes.items():
        for moment in moments:
            it = ((name, moment, '{:02d}'.format(i+1)) for i in range(size))
            columns.extend(it)

    names = ('feature', 'statistics', 'number')
    columns = pd.MultiIndex.from_tuples(columns, names=names)

    # More efficient to slice if indexes are sorted.
    return columns.sort_values() 
开发者ID:crowdAI,项目名称:crowdai-musical-genre-recognition-starter-kit,代码行数:20,代码来源:features.py

示例3: nct_kurt_bug

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def nct_kurt_bug():
    '''test for incorrect kurtosis of nct

    D. Hogben, R. S. Pinkham, M. B. Wilk: The Moments of the Non-Central
    t-DistributionAuthor(s): Biometrika, Vol. 48, No. 3/4 (Dec., 1961),
    pp. 465-468
    '''
    from numpy.testing import assert_almost_equal
    mvsk_10_1 = (1.08372, 1.325546, 0.39993, 1.2499424941142943)
    assert_almost_equal(stats.nct.stats(10, 1, moments='mvsk'), mvsk_10_1, decimal=6)
    c1=np.array([1.08372])
    c2=np.array([.0755460, 1.25000])
    c3 = np.array([.0297802, .580566])
    c4 = np.array([0.0425458, 1.17491, 6.25])

    #calculation for df=10, for arbitrary nc
    nc = 1
    mc1 = c1.item()
    mc2 = (c2*nc**np.array([2,0])).sum()
    mc3 = (c3*nc**np.array([3,1])).sum()
    mc4 = c4=np.array([0.0425458, 1.17491, 6.25])
    mvsk_nc = mc2mvsk((mc1,mc2,mc3,mc4)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:24,代码来源:check_moments.py

示例4: _set_start_params

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def _set_start_params(self, start_params=None, use_kurtosis=False):
        if start_params is not None:
            self.start_params = start_params
        else:
            from statsmodels.regression.linear_model import OLS
            res_ols = OLS(self.endog, self.exog).fit()
            start_params = 0.1*np.ones(self.k_params)
            start_params[:self.k_vars] = res_ols.params

            if self.fix_df is False:

                if use_kurtosis:
                    kurt = stats.kurtosis(res_ols.resid)
                    df = 6./kurt + 4
                else:
                    df = 5

                start_params[-2] = df
                #TODO adjust scale for df
                start_params[-1] = np.sqrt(res_ols.scale)

            self.start_params = start_params 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:24,代码来源:tmodel.py

示例5: test_kurt

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def test_kurt(self):
        from scipy.stats import kurtosis
        alt = lambda x: kurtosis(x, bias=False)
        self._check_stat_op('kurt', alt)

        index = MultiIndex(levels=[['bar'], ['one', 'two', 'three'], [0, 1]],
                           labels=[[0, 0, 0, 0, 0, 0], [0, 1, 2, 0, 1, 2],
                                   [0, 1, 0, 1, 0, 1]])
        s = Series(np.random.randn(6), index=index)
        tm.assert_almost_equal(s.kurt(), s.kurt(level=0)['bar'])

        # test corner cases, kurt() returns NaN unless there's at least 4
        # values
        min_N = 4
        for i in range(1, min_N + 1):
            s = Series(np.ones(i))
            df = DataFrame(np.ones((i, i)))
            if i < min_N:
                assert np.isnan(s.kurt())
                assert np.isnan(df.kurt()).all()
            else:
                assert 0 == s.kurt()
                assert (df.kurt() == 0).all() 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:25,代码来源:test_analytics.py

示例6: test_kurt

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def test_kurt(self):
        from scipy.stats import kurtosis

        def alt(x):
            if len(x) < 4:
                return np.nan
            return kurtosis(x, bias=False)

        self._check_stat_op('kurt', alt)

        index = MultiIndex(levels=[['bar'], ['one', 'two', 'three'], [0, 1]],
                           labels=[[0, 0, 0, 0, 0, 0],
                                   [0, 1, 2, 0, 1, 2],
                                   [0, 1, 0, 1, 0, 1]])
        df = DataFrame(np.random.randn(6, 3), index=index)

        kurt = df.kurt()
        kurt2 = df.kurt(level=0).xs('bar')
        tm.assert_series_equal(kurt, kurt2, check_names=False)
        assert kurt.name is None
        assert kurt2.name == 'bar' 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:23,代码来源:test_analytics.py

示例7: get_stat_funs

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def get_stat_funs():
    """
    Previous version uses lambdas.
    """
    stat_funs = []
    
    stats = [len, np.min, np.max, np.median, np.std, skew, kurtosis] + 19 * [np.percentile]
    stats_kwargs = [{} for i in range(7)] + [{'q': i} for i in np.linspace(0.05, 0.95, 19)]

    for stat, stat_kwargs in zip(stats, stats_kwargs):
        stat_funs.append(_StatFunAdaptor(stat,**stat_kwargs))
        stat_funs.append(_StatFunAdaptor(stat, np.diff, **stat_kwargs))
        stat_funs.append(_StatFunAdaptor(stat, diff2, **stat_kwargs))
        stat_funs.append(_StatFunAdaptor(stat, np.unique, **stat_kwargs))
        stat_funs.append(_StatFunAdaptor(stat, np.unique, np.diff, **stat_kwargs))
        stat_funs.append(_StatFunAdaptor(stat, np.unique, diff2, **stat_kwargs))
    return stat_funs 
开发者ID:mengli,项目名称:MachineLearning,代码行数:19,代码来源:pipline.py

示例8: test_kurtosis

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def test_kurtosis(self):
        #   sum((testcase-mean(testcase,axis=0))**4,axis=0)/((sqrt(var(testcase)*3/4))**4)/4
        #   sum((test2-mean(testmathworks,axis=0))**4,axis=0)/((sqrt(var(testmathworks)*4/5))**4)/5
        #   Set flags for axis = 0 and
        #   fisher=0 (Pearson's defn of kurtosis for compatiability with Matlab)
        y = stats.kurtosis(self.testmathworks,0,fisher=0,bias=1)
        assert_approx_equal(y, 2.1658856802973,10)

        # Note that MATLAB has confusing docs for the following case
        #  kurtosis(x,0) gives an unbiased estimate of Pearson's skewness
        #  kurtosis(x)  gives a biased estimate of Fisher's skewness (Pearson-3)
        #  The MATLAB docs imply that both should give Fisher's
        y = stats.kurtosis(self.testmathworks,fisher=0,bias=0)
        assert_approx_equal(y, 3.663542721189047,10)
        y = stats.kurtosis(self.testcase,0,0)
        assert_approx_equal(y,1.64) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:test_stats.py

示例9: plot_information_table

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def plot_information_table(ic_data):
    """
    IC 统计量
    """
    ic_summary_table = pd.DataFrame()
    ic_summary_table["IC Mean"] = ic_data.mean()
    ic_summary_table["IC std."] = ic_data.std()
    ic_summary_table["Risk-Adjusted IC (IR)"] = ic_data.mean() / ic_data.std()
    t_stat, p_value = stats.ttest_1samp(ic_data, 0)
    ic_summary_table["t-stat (IC)"] = t_stat
    ic_summary_table["p-value (IC)"] = p_value
    ic_summary_table["IC Skew"] = stats.skew(ic_data)
    ic_summary_table["IC Kurtosis"] = stats.kurtosis(ic_data)

    print("Information Analysis")
    plotting_utils.print_table(ic_summary_table.apply(lambda x: x.round(3)).T) 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:18,代码来源:plotting.py

示例10: compute_kurtosis

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def compute_kurtosis(data):
    """Kurtosis of the data (per channel).

    Parameters
    ----------
    data : ndarray, shape (n_channels, n_times)

    Returns
    -------
    output : ndarray, shape (n_channels,)

    Notes
    -----
    Alias of the feature function: **kurtosis**
    """
    ndim = data.ndim
    return stats.kurtosis(data, axis=ndim - 1, fisher=False) 
开发者ID:mne-tools,项目名称:mne-features,代码行数:19,代码来源:univariate.py

示例11: test_describe_axis_none

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def test_describe_axis_none(self):
        x = np.vstack((np.ones((3, 4)), 2 * np.ones((2, 4))))

        # expected values
        e_nobs, e_minmax = (20, (1.0, 2.0))
        e_mean = 1.3999999999999999
        e_var = 0.25263157894736848
        e_skew = 0.4082482904638634
        e_kurt = -1.8333333333333333

        # actual values
        a = stats.describe(x, axis=None)

        assert_equal(a.nobs, e_nobs)
        assert_almost_equal(a.minmax, e_minmax)
        assert_almost_equal(a.mean, e_mean)
        assert_almost_equal(a.variance, e_var)
        assert_array_almost_equal(a.skewness, e_skew, decimal=13)
        assert_array_almost_equal(a.kurtosis, e_kurt, decimal=13) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:21,代码来源:test_stats.py

示例12: test_tukeylambda_stats_ticket_1545

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def test_tukeylambda_stats_ticket_1545():
    # Some test for the variance and kurtosis of the Tukey Lambda distr.
    # See test_tukeylamdba_stats.py for more tests.

    mv = stats.tukeylambda.stats(0, moments='mvsk')
    # Known exact values:
    expected = [0, np.pi**2/3, 0, 1.2]
    assert_almost_equal(mv, expected, decimal=10)

    mv = stats.tukeylambda.stats(3.13, moments='mvsk')
    # 'expected' computed with mpmath.
    expected = [0, 0.0269220858861465102, 0, -0.898062386219224104]
    assert_almost_equal(mv, expected, decimal=10)

    mv = stats.tukeylambda.stats(0.14, moments='mvsk')
    # 'expected' computed with mpmath.
    expected = [0, 2.11029702221450250, 0, -0.02708377353223019456]
    assert_almost_equal(mv, expected, decimal=10) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:20,代码来源:test_distributions.py

示例13: test_sparse_grid_moments

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def test_sparse_grid_moments(self):
        mu = 1
        sigma = 2
        variance = sigma**2
        x1 = Parameter(distribution="Gaussian", shape_parameter_A=mu, shape_parameter_B=variance, order=6)
        x2 = Parameter(distribution="Gaussian", shape_parameter_A=mu, shape_parameter_B=variance, order=6)
        del variance
        parameters = [x1, x2]
        parameters = [x1, x2]
        basis = Basis('sparse-grid', level=5, growth_rule='linear')
        uqProblem = Poly(parameters, basis, method='numerical-integration')
        uqProblem.set_model(rosenbrock_fun)
        mean, variance = uqProblem.get_mean_and_variance()
        skewness, kurtosis = uqProblem.get_skewness_and_kurtosis()
        large_number = 2000000
        s = sigma * np.random.randn(large_number,2) + mu
        model_evals = evaluate_model(s, rosenbrock_fun)
        mean_mc = np.mean(model_evals)
        variance_mc = np.var(model_evals)
        skewness_mc = skew(model_evals)
        np.testing.assert_array_less(np.abs(mean-mean_mc)/mean * 100.0,  1.0)
        np.testing.assert_array_less(np.abs(variance-variance_mc)/variance * 100.0,  5.0)
        np.testing.assert_array_less(np.abs(skewness-skewness_mc)/skewness * 100.0,  5.0) 
开发者ID:Effective-Quadratures,项目名称:Effective-Quadratures,代码行数:25,代码来源:test_statistics.py

示例14: test_parameter_mc_least_squares_moments

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def test_parameter_mc_least_squares_moments(self):
        x1 = Parameter(distribution='uniform',lower =0.0, upper=1.0, order=7)
        x2 = Parameter(distribution='Beta',lower =0.0, upper=1.0, shape_parameter_A = 1.6, shape_parameter_B=3.2 , order=7)
        myparameters = [x1, x2]
        mybasis = Basis('tensor-grid')
        mypoly = Poly(myparameters, mybasis, method='numerical-integration')
        mypoly.set_model(rosenbrock_fun)
        mean, variance = mypoly.get_mean_and_variance()
        skewness, kurtosis = mypoly.get_skewness_and_kurtosis()
        large_number = 3000000
        s = np.random.rand(large_number, 2)
        x1_samples = x1.get_icdf(s[:,0])
        x2_samples = x2.get_icdf(s[:,1])
        s = np.vstack([x1_samples, x2_samples]).T
        model_evals = evaluate_model(s, rosenbrock_fun)
        mean_mc = np.mean(model_evals)
        variance_mc = np.var(model_evals)
        skewness_mc = skew(model_evals)
        np.testing.assert_array_less(np.abs(mean-mean_mc)/mean * 100.0,  1.0)
        np.testing.assert_array_less(np.abs(variance-variance_mc)/variance * 100.0,  5.0)
        np.testing.assert_array_less(np.abs(skewness-skewness_mc)/skewness * 100.0,  5.0) 
开发者ID:Effective-Quadratures,项目名称:Effective-Quadratures,代码行数:23,代码来源:test_statistics.py

示例15: test__rs

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import kurtosis [as 别名]
def test__rs(a):
    rs = np.random.RandomState(1234)

    # create an array with a pretty ridiculous outlier effect to try and fix
    y = rs.normal(size=(100, 1000))
    y[0] += 1000
    y[:, 0] += 1000
    out = correct._rs(y, axis=a)

    # max will always be less than one, min will always be greater than zero
    assert np.all(out.max(axis=a) <= 1) and np.all(out.min(axis=a) >= 0)

    # we should have reduced skewness / kurtosis compared to the original
    assert np.all(sstats.skew(out, axis=a) < sstats.skew(y, axis=a))
    assert np.all(sstats.kurtosis(out, axis=a) < sstats.kurtosis(y, axis=a))

    # this is a weird test; we're gonna bin the data at 0.2 intervals and make
    # sure no bins are empty. if one is something probably went wrong, right?
    for low in np.arange(0, 1, 0.2):
        hi = low + 0.2 + np.spacing(1)  # include 1
        assert np.all(np.sum(np.logical_and(out >= low, out < hi), axis=a) > 0) 
开发者ID:rmarkello,项目名称:abagen,代码行数:23,代码来源:test_correct.py


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