2013-11-09 103 views
8

我有一個多元蒙特卡羅隱馬爾可夫解決的問題:隱馬爾可夫在PyMC3

x[k] = f(x[k-1]) + B u[k] 
    y[k] = g(x[k]) 

其中:

x[k] the hidden states (Markov dynamics) 
y[k] the observed data 
u[k] the stochastic driving process 

是PyMC3已經足夠成熟來處理這個問題,或者我應該留在版本2.3?其次,任何在PyMC框架中對HM模型的引用都會很感激。謝謝。

- Henk

+0

因爲人們可以看到HMM的狀態空間模型的特定情況下,這個包PySSM可能幫助你:) 回覆:https://bitbucket.org/christophermarkstrickland/pyssm 論文:http://www.jstatsoft.org/v57/i06/paper –

回答

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) 

我想你需要將你的vel建模爲RV列表。他們也有一些依賴性。

這裏是原題: PyMC: Parameter estimation in a Markov system

下面是完整的例子如IPython的筆記本: http://nbviewer.ipython.org/github/sotte/random_stuff/blob/master/PyMC%20-%20Simple%20Markov%20Chain.ipynb