-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Particle filter proposal implementation #1080
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but would be nice to remove global seed setting from tests.
stonesoup/proposal/simple.py
Outdated
post_log_weights = np.array([mvn.logpdf(sample, | ||
np.array(update.mean).reshape(-1), | ||
update.covar) | ||
for sample, update in zip(samples, updates)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better to handle custom types, as mvn converts to float arrays before taking difference.
post_log_weights = np.array([mvn.logpdf(sample, | |
np.array(update.mean).reshape(-1), | |
update.covar) | |
for sample, update in zip(samples, updates)]) | |
post_log_weights = np.array([mvn.logpdf(sample - update.mean.reshape(-1), cov=update.covar) | |
for sample, update in zip(samples, updates)]) |
Also, here you use update.mean
but above update.state_vector
. Should these not be both the same? (In theory they should be anyway I guess? but...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point, mean
and state_vector
are equal in this case. I changed it
def test_prior_proposal(): | ||
# test that the proposal as prior and basic PF implementation | ||
# yield same results, since they are driven by the transition model | ||
np.random.seed(16549) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #1064 which aims to remove any setting of global random seeds in tests.
May need to add random state option to Proposal to support this, like models have.
…the state_vectr instead of mean and handling of arrays
This PR updates the particle filter implementation with proposals, in particular prior as proposal and (local) kalman filter.
This is developed by @sglvladi and myself.
Now the particle filter uses prior as proposal as default, otherwise a Kalman filter proposal can be used.
Since in the prediction step we need to perform an update, we have modified as well the distance hypothesiser to include the measurements (or detections) to perform correctly the predict-update step.
We have implemented the local Lalman Filter proposal which propagates each particle using the kalman filter predict and update and then samples once for each particle the new state (before doing the particle update).
There is another way, commonly known as global Kalman Filter, where the particle distribution is approximated by a gaussian, which is propagated using the Kalman Filter and then a new set of particles is drawn from the new state. However, we encountered a number of issues in the making it working accordingly, in particular with problems with weights normalisation during the data-association step. I will open an issue to try to get to the bottom of this.
Summary paper that highlights the two implementations
We have not modified the probability hypothesier (yet) because there is the need of a fix proposed in #802 (PDA and JPDA to work with particle state) and we don't want to duplicate the work.
A couple of stone soup examples are :
single target no data association case
data association case