PyMC3中的隐马尔可夫

hen*_*enk 8 python hidden-markov-models pymc

我有一个多变量蒙特卡罗隐马尔可夫问题要解决:

   x[k] = f(x[k-1]) + B u[k]
   y[k] = g(x[k])
Run Code Online (Sandbox Code Playgroud)

哪里:

x[k] the hidden states (Markov dynamics)
y[k] the observed data
u[k] the stochastic driving process
Run Code Online (Sandbox Code Playgroud)

PyMC3已经足够成熟以解决这个问题,还是应该继续使用2.3版?其次,非常感谢PyMC框架中对HM模型的任何引用.谢谢.

- 亨克

Ste*_*fan 2

我对 PyMC 2.x 做了类似的事情。不过我的你并不依赖时间。这是我的例子。

# we're using `some_tau` for the noise throughout the example.
# this should be replaced with something more meaningful.
some_tau = 1 / .5**2

# PRIORS
# we don't know too much about the velocity, might be pos. or neg. 
vel = pm.Normal("vel", mu=0, tau=some_tau)

# MODEL
# next_state = prev_state + vel (and some gaussian noise)
# That means that each state depends on the prev_state and the vel.
# We save the states in a list.
states = [pm.Normal("s0", mu=true_positions[0], tau=some_tau)]
for i in range(1, len(true_positions)):
    states.append(pm.Normal(name="s" + str(i),
                            mu=states[-1] + vel,
                            tau=some_tau))

# observation with gaussian noise
obs = pm.Normal("obs", mu=states, tau=some_tau, value=true_positions, observed=True)
Run Code Online (Sandbox Code Playgroud)

我想你需要将你的 vel 建模为 RV 列表。他们可能也有一定的依赖性。

这是原始问题: PyMC: Markov system 中的参数估计

以下是 IPython 笔记本的完整示例: http://nbviewer.ipython.org/github/sotte/random_stuff/blob/master/PyMC%20-%20Simple%20Markov%20Chain.ipynb