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


Python KalmanFilter.em_vars方法代码示例

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


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

示例1: test_kalman_fit

# 需要导入模块: from pykalman import KalmanFilter [as 别名]
# 或者: from pykalman.KalmanFilter import em_vars [as 别名]
def test_kalman_fit():
    # check against MATLAB dataset
    kf = KalmanFilter(
        data.transition_matrix,
        data.observation_matrix,
        data.initial_transition_covariance,
        data.initial_observation_covariance,
        data.transition_offsets,
        data.observation_offset,
        data.initial_state_mean,
        data.initial_state_covariance,
        em_vars=['transition_covariance', 'observation_covariance'])

    loglikelihoods = np.zeros(5)
    for i in range(len(loglikelihoods)):
        loglikelihoods[i] = kf.loglikelihood(data.observations)
        kf.em(X=data.observations, n_iter=1)

    assert_true(np.allclose(loglikelihoods, data.loglikelihoods[:5]))

    # check that EM for all parameters is working
    kf.em_vars = 'all'
    n_timesteps = 30
    for i in range(len(loglikelihoods)):
        kf.em(X=data.observations[0:n_timesteps], n_iter=1)
        loglikelihoods[i] = kf.loglikelihood(data.observations[0:n_timesteps])
    for i in range(len(loglikelihoods) - 1):
        assert_true(loglikelihoods[i] < loglikelihoods[i + 1])
开发者ID:Answeror,项目名称:pykalman,代码行数:30,代码来源:test_standard.py


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