I am currently working on a package in C++ to easily implement different Statistical Filters, and after implementing various versions of the Kalman Filter I decided to start working on the Particle Filter. For that, I have been using some of the resources available online, such as the Probabilistic Robotics book or the Cyril Stachniss online lectures on YouTube. The first rock I encountered consisted of sampling in non-parametric probability distributions. When implementing the Sampling procedure from the Particle filter Chapter 4 from the book I don't exactly see how it can be done, and the explanation doesn't clarify it to me completely. What this says is:
Line 4 generates a hypothetical state xt for time t based on the particle xt−1 and the control ut . The resulting sample is indexed by m, indicating that it is generated from the m-th particle in Xt−1 . This step involves sampling from the next state distribution p(xt | ut , xt−1 ). To implement this step, one needs to be able to sample from p(xt | ut , xt−1 ). The ability to sample from the state transition probability is not given for arbitrary distributions p(xt | ut , xt−1 ). However, many major distributions in this book possess efficient algorithms for generating samples. The set of particles resulting from iterating Step 4 M times is the filter’s representation of bel(xt ).
How can we sample from p(xt|ut,xt−1)? Do I need to apply the input from the previous state to the current one and maybe add some noise? Does anyone know any source I can look for on sampling in non-parametric distributions? I am especially struggling with how would we obtain the likelihood of a given point if we only know the weights of the particles and their weights, which is just a discrete set of points. How can we obtain a continuous distribution for the probability?
I checked this other question in which they mention forwarding the input with the dynamic model of the system, but I am not totally convinced by the explanation given.
Edit: I am starting to think that it might not be possible to fit a general Particle Filter code, where only inputs and/or pointers to external functions are needed for every case, but better to have some of the functions that can be used for resampling and other operations, but not the filter as a whole. Especially taking into consideration the step in which we need to find the probability of the current measure given the state of each of the particles. How can the comparison be even implemented?