nchopin / particles

Sequential Monte Carlo in python
MIT License
387 stars 73 forks source link

Question : Is it possible to use control commands `u` in `PX`? #84

Open OriginalPou opened 2 months ago

OriginalPou commented 2 months ago

Hello,

I am working on a robotics application where I am interested in learning the motion and measurement model parameters of a ground robot, and wanted to know if the the Bayesian inference methods for ssm such as the $SMC^2$ algorithm and the Particle marginal Metropolis-Hastings algorithm could be used for exploring parameter distributions when state transition is not only conditional on the previous state but also a control input (odometry for example). The state transition becomes : $$Xt | (X{t-1}=x_{t-1} , U_t = ut) = f(x{t-1}, u_t) + \omega_t ~~~~~ \omega \sim N(0,\sigma_x^2)$$ While I know that the library can be easily modified to support my study case, I just wanted to know if I am missing something in the theory because (if I am not mistaken) all the examples in the book, papers and documentation consider only HMMs without control inputs.

Thank you very much for the work you've done creating and maintaining this library :100:

nchopin commented 2 months ago

Hi, yes, you're right, all the HMMs considered in the book etc are without control inputs. One quick and dirty way to deal with your issue is to define the $u_t$ as global variables, but that's not very elegant, of course.

As I often say, if your state-space model is complicated (in some way), and if you just want to implement the bootstrap filter, you might be better off defining directly the Feynman-Kac model that corresponds to the bootstrap filter. So a better way might be to implement directly a FeynmanKac class, where the sequence of $u_t$ is simply an attribute of the class. More details in this notebook tutorial.

BTW, am I assuming correctly that the sequence of $u_t$ is known in advance? Otherwise, if you acquire the $u_t$ sequentially (i.e. you know the value of $u_t$ only at time $t$, but not before), then things get a bit more complicated I guess.

I am going to mark this as "feature request" and keep it open, so that I can think a bit more about it.

Thank you very much for the work you've done creating and maintaining this library 💯

Thanks, I appreciate it!

OriginalPou commented 2 months ago

Thank you very much for your quick reply. Yes I do know the sequence of $u_t$ in advance.

I am very interested in hearing your future thoughts about this study case :raised_hands: