lindermanlab / ssm

Bayesian learning and inference for state space models
MIT License
570 stars 199 forks source link

Question about alpha calculation in forward pass #168

Open ncguilbeault opened 5 months ago

ncguilbeault commented 5 months ago

Hi,

Thank you for developing this fantastic tool!

I have a question regarding the use of your package for performing online inference. Specifically, I am trying to implement the equation 𝛼hat = 𝑃(𝑧𝑛 ∣ π‘₯1, … , π‘₯𝑛) as described in Bishop (2006).

Does your package or API include a function that calculates this directly? From my review of the source code, the closest functionality I found is in the forward_pass function where the alphas are computed (this line in messages.py). Is this 𝛼 the same as 𝛼hat?

Any insights or guidance you can provide would be greatly appreciated.

Best regards, Nick

joacorapela commented 4 months ago

Hello Nick,

$\hat{\alpha}_n=P(z_n|x_1,\ldots,x_n)$, in Eq. 13.55 of Bishop, 2006, is computed inside function hmm_filter in variable pz_tt, but it is not returned by this fuction. It only returns $P(z_{n+1}|x_1,\ldots,x_n)$. It would be better if hmm_filter, and function filter which calls it, returned both of these quantities.

@slinderman would a pull request changing the return values of these functions be welcomed?

Joaquin