dstl / Stone-Soup

A software project to provide the target tracking community with a framework for the development and testing of tracking algorithms.
https://stonesoup.rtfd.io
MIT License
388 stars 128 forks source link

Add logpdf method to models, and implement in particle filter #744

Closed sdhiscocks closed 1 year ago

sdhiscocks commented 1 year ago

This avoids a number a nugatory calculations switching in/out of log space with Probability class.

Also modified mean/covar calculation in particle state to use float array to avoid similar issue caused by Probability class forcing use of object arrays.

codecov[bot] commented 1 year ago

Codecov Report

Base: 94.91% // Head: 94.92% // Increases project coverage by +0.00% :tada:

Coverage data is based on head (bdd3a86) compared to base (cf0dba1). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #744 +/- ## ======================================= Coverage 94.91% 94.92% ======================================= Files 171 171 Lines 8443 8454 +11 Branches 1234 1232 -2 ======================================= + Hits 8014 8025 +11 Misses 317 317 Partials 112 112 ``` | Flag | Coverage Δ | | |---|---|---| | integration | `69.74% <84.21%> (-0.05%)` | :arrow_down: | | unittests | `92.03% <100.00%> (+0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://codecov.io/gh/dstl/Stone-Soup/pull/744?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl) | Coverage Δ | | |---|---|---| | [stonesoup/models/base.py](https://codecov.io/gh/dstl/Stone-Soup/pull/744/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl#diff-c3RvbmVzb3VwL21vZGVscy9iYXNlLnB5) | `100.00% <100.00%> (ø)` | | | [stonesoup/models/measurement/nonlinear.py](https://codecov.io/gh/dstl/Stone-Soup/pull/744/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl#diff-c3RvbmVzb3VwL21vZGVscy9tZWFzdXJlbWVudC9ub25saW5lYXIucHk=) | `98.93% <100.00%> (+<0.01%)` | :arrow_up: | | [stonesoup/resampler/particle.py](https://codecov.io/gh/dstl/Stone-Soup/pull/744/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl#diff-c3RvbmVzb3VwL3Jlc2FtcGxlci9wYXJ0aWNsZS5weQ==) | `100.00% <100.00%> (ø)` | | | [stonesoup/types/numeric.py](https://codecov.io/gh/dstl/Stone-Soup/pull/744/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl#diff-c3RvbmVzb3VwL3R5cGVzL251bWVyaWMucHk=) | `100.00% <100.00%> (ø)` | | | [stonesoup/types/state.py](https://codecov.io/gh/dstl/Stone-Soup/pull/744/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl#diff-c3RvbmVzb3VwL3R5cGVzL3N0YXRlLnB5) | `99.74% <100.00%> (ø)` | | | [stonesoup/updater/particle.py](https://codecov.io/gh/dstl/Stone-Soup/pull/744/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl#diff-c3RvbmVzb3VwL3VwZGF0ZXIvcGFydGljbGUucHk=) | `98.78% <100.00%> (+0.01%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dstl)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

hpritchett-dstl commented 1 year ago

This looks good to me!

The change made to the calculation of the mean in the particle state resulted in a significant runtime improvement, with an example particle filter tracker going from 34.1s runtime to 11.8s, while reproducing identical results.

particle_state_mean_change