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


Python Representation._initialize_representation方法代码示例

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


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

示例1: test_representation

# 需要导入模块: from statsmodels.tsa.statespace.representation import Representation [as 别名]
# 或者: from statsmodels.tsa.statespace.representation.Representation import _initialize_representation [as 别名]
def test_representation():
    # Test an invalid number of states
    def zero_kstates():
        mod = Representation(1, 0)
    assert_raises(ValueError, zero_kstates)

    # Test an invalid endogenous array
    def empty_endog():
        endog = np.zeros((0,0))
        mod = Representation(endog, k_states=2)
    assert_raises(ValueError, empty_endog)

    # Test a Fortran-ordered endogenous array (which will be assumed to be in
    # wide format: k_endog x nobs)
    nobs = 10
    k_endog = 2
    endog = np.asfortranarray(np.arange(nobs*k_endog).reshape(k_endog,nobs)*1.)
    mod = Representation(endog, k_states=2)
    assert_equal(mod.nobs, nobs)
    assert_equal(mod.k_endog, k_endog)

    # Test a C-ordered endogenous array (which will be assumed to be in
    # tall format: nobs x k_endog)
    nobs = 10
    k_endog = 2
    endog = np.arange(nobs*k_endog).reshape(nobs,k_endog)*1.
    mod = Representation(endog, k_states=2)
    assert_equal(mod.nobs, nobs)
    assert_equal(mod.k_endog, k_endog)

    # Test getting the statespace representation
    assert_equal(mod._statespace, None)
    mod._initialize_representation()
    assert(mod._statespace is not None)
开发者ID:andreas-koukorinis,项目名称:statsmodels,代码行数:36,代码来源:test_representation.py

示例2: test_representation_pickle

# 需要导入模块: from statsmodels.tsa.statespace.representation import Representation [as 别名]
# 或者: from statsmodels.tsa.statespace.representation.Representation import _initialize_representation [as 别名]
def test_representation_pickle():
    nobs = 10
    k_endog = 2
    endog = np.asfortranarray(np.arange(nobs * k_endog).reshape(k_endog, nobs) * 1.)
    mod = Representation(endog, k_states=2)
    pkl_mod = cPickle.loads(cPickle.dumps(mod))

    assert_equal(mod.nobs, pkl_mod.nobs)
    assert_equal(mod.k_endog, pkl_mod.k_endog)

    mod._initialize_representation()
    pkl_mod._initialize_representation()
    assert_equal(mod.design, pkl_mod.design)
    assert_equal(mod.obs_intercept, pkl_mod.obs_intercept)
    assert_equal(mod.initial_variance, pkl_mod.initial_variance)
开发者ID:cong1989,项目名称:statsmodels,代码行数:17,代码来源:test_pickle.py


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