-
Notifications
You must be signed in to change notification settings - Fork 143
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
Implementation of Non-Gaussian transition models #1043
base: main
Are you sure you want to change the base?
Conversation
Initial commit to introduce Levy (non-Gaussian) transition models
Co-authored-by: Christopher Sherman <[email protected]>
…h initialisation.
…very well in sphinx.
b85df1e
to
de58f3b
Compare
docs/tutorials/11_LevyTransitionModels_&_MarginalisedParticleFilter.ipynb
Outdated
Show resolved
Hide resolved
...als/.ipynb_checkpoints/11_LevyTransitionModels_&_MarginalisedParticleFilter-checkpoint.ipynb
Outdated
Show resolved
Hide resolved
@hpritchett-dstl Additionally, I noticed that some of my formatting changes might have affected other parts of the repository that aren’t mine. I’ll need more time to undo those, but it might be helpful if we had standardized code styles throughout the repository. For example:
Lastly, it would be really helpful to have a local development setup that mirrors the CircleCI test environment. This way, I could run the tests locally and address any issues before pushing changes. A docker image would be great! |
f788491
to
19d9940
Compare
19d9940
to
f98c93b
Compare
99d144d
to
9209cf0
Compare
9209cf0
to
dff4b12
Compare
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've made some comments on the tutorial that could do with being applied throughout to make the documentation render properly.
There is some guidance here which might be useful: https://sphinx-gallery.github.io/stable/syntax.html - you can also render the docs locally by running python -m sphinx -W docs/source docs/build
.
# The state of the target can be represented as 2D Cartesian coordinates, $\left[x, \dot x, y, \dot y\right]^{\top}$, modelling both its position and velocity. A simple truth path is created with a sampling rate of 1 Hz. | ||
|
||
# In[2]: |
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 previous comment (check my editing of the maths here though)
# The state of the target can be represented as 2D Cartesian coordinates, $\left[x, \dot x, y, \dot y\right]^{\top}$, modelling both its position and velocity. A simple truth path is created with a sampling rate of 1 Hz. | |
# In[2]: | |
# %% | |
# The state of the target can be represented as 2D Cartesian coordinates, :math`[x, \dot{x}, y, \dot{y}]^{\top}`, modelling both its position and velocity. A simple truth path is created with a sampling rate of 1 Hz. |
# Consider the scenario where the target evolves according to the Langevin model, driven by a normal sigma-mean mixture with the mixing distribution being the $\alpha$-stable distribution. | ||
|
||
# In[1]: |
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.
Each section of text in the tutorial (i.e. not code) needs to begin with # %%
. To format mathematical symbols you need to wrap in ":math:maths_goes_here
". You can also remove all the # In[]
lines from the tutorial file.
# Consider the scenario where the target evolves according to the Langevin model, driven by a normal sigma-mean mixture with the mixing distribution being the $\alpha$-stable distribution. | |
# In[1]: | |
# %% | |
# Consider the scenario where the target evolves according to the Langevin model, driven by a normal sigma-mean mixture with the mixing distribution being the :math:`\alpha`-stable distribution. |
from stonesoup.types.groundtruth import GroundTruthPath, GroundTruthState | ||
from stonesoup.models.base_driver import NoiseCase | ||
from stonesoup.models.driver import AlphaStableNSMDriver | ||
from stonesoup.models.transition.levy_linear import LevyLangevin, CombinedLinearLevyTransitionModel | ||
|
||
# And the clock starts | ||
start_time = datetime.now().replace(microsecond=0) |
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.
Could these initial imports sit in the first block of code rather than in the middle of the text?
start_time = datetime.now().replace(microsecond=0) | ||
|
||
|
||
# The `LevyLangevin` class creates a one-dimensional Langevin model, driven by the $\alpha$-stable NSM mixture process defined in the `AlphaStableNSMDriver` class. |
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.
If you add ":class:~.class_name
" around your class names they create links within the tutorial to the documentation pages for the class.
# The `LevyLangevin` class creates a one-dimensional Langevin model, driven by the $\alpha$-stable NSM mixture process defined in the `AlphaStableNSMDriver` class. | |
# The :class:`~.LevyLangevin` class creates a one-dimensional Langevin model, driven by the :math:`\alpha`-stable NSM mixture process defined in the `AlphaStableNSMDriver` class. |
# <!-- and in the $\alpha$-stable law is a function of the conditional Gaussian mean $\mu_W$ | ||
# | ||
# where $\beta=\begin{cases} 1, \quad \mu_W \neq 0 \\ 0, \quad \text{otherwise} \end{cases}$ with $\beta=0$ being the a symmetric stable distribution. | ||
# | ||
# $\sigma=\frac{\mathbb{E}|w|^\alpha \Gamma(2-\alpha) \cos(\pi \alpha / 2))}{1- \alpha}$ represent the scale parameter and $\beta=$ controlling the skewness of the stable distribution. --> | ||
# |
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.
Does this part need to be removed?
@@ -0,0 +1,426 @@ | |||
from abc import abstractmethod |
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 file (stonesoup.models.base_driver) needs to be added to the docs/source/stonesoup.models.rst file for it to appear in the documentation. It may be worth creating a subfolder for driver models similar to clutter models or transition models.
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.
As the Gaussian model lives within models.base
, I created a separate LevyModel
class as it should be as general as the Gaussian model, with a similar interface. Would it help if I created a separate stonesoup/models/driver/
folder to store the implementation of the drivers there? But I leave the base_driver.py
under stonesoup/models/
.
@@ -0,0 +1,251 @@ | |||
from typing import Callable, Generator, Optional, Union |
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 file (stonesoup.models.driver) needs to be added to the docs/source/stonesoup.models.rst file for it to appear in the documentation.
@hpritchett-dstl
Features:
Refactored:
LevyLangevin
modelTodo:
Additional comments:
I believe the current design is a good compromise between speed and compatibility with the existing stone soup framework to avoid introducing any breaking changes. The newly introduced models decouple the deterministic (transition model) and non-deterministic (noise driver) components. That being said, suggestions are welcome and highly appreciated.