Skip to content
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

Open
wants to merge 70 commits into
base: main
Choose a base branch
from

Conversation

zhenyuen
Copy link

@zhenyuen zhenyuen commented Jun 16, 2024

@hpritchett-dstl

Features:

  1. Introduce a new family of transition models that generalise transition models driven by white noise to the Levy process.
  2. Provides support for normal sigma-mean and normal variance-mean mixture processes.
  3. Users can inject the desired driving processes into the selected transition model
  4. Introduce marginalised particle filtering for inferencing the newly-introduced class of models.
  5. Added a tutorial notebook for the new class of models and marginalised particle filter

Refactored:

  1. Improve inference speed for Levy models with known state transition matrices, e.g. LevyLangevin model
  2. Wrote minimal tests to lock down the behaviour of the introduced models. Some of Simon's students will still actively contribute to his work here, and I would require their help to improve the test coverage.
  3. Better separation of concerns/class design than before.

Todo:

  1. Implementation of PDF and log PDF functions, certain Levy distributions have non-trivial PDFs/CDFs, currently looking into inverse FFT methods involving characteristic functions.
  2. Provide support for more models, e.g. Singer
  3. Improve tests.

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.

zhenyuen and others added 30 commits May 11, 2024 01:13
Initial commit to introduce Levy (non-Gaussian) transition models
Co-authored-by: Christopher Sherman <146717651+csherman-dstl@users.noreply.github.com>
@zhenyuen
Copy link
Author

@hpritchett-dstl
I believe I’ve addressed all your comments and refactored the code accordingly. However, my tests on CircleCI for Python 3.8 seem to be failing due to the KS test from SciPy. I’m not entirely sure what’s causing this, so I’d appreciate it if you could take a look and help troubleshoot.

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:

  1. Using absolute imports instead of relative imports
  2. Configuring flake8 and black consistently, ideally with a pre-commit hook

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!

@zhenyuen zhenyuen force-pushed the levy-models-slow branch 2 times, most recently from f788491 to 19d9940 Compare November 16, 2024 10:57
Copy link
Contributor

@nperree-dstl nperree-dstl left a 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.

Comment on lines +24 to +26
# 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]:
Copy link
Contributor

@nperree-dstl nperree-dstl Jan 3, 2025

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)

Suggested change
# 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.

Copy link
Author

@zhenyuen zhenyuen Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also render the docs locally by running python -m sphinx -W docs/source docs/build.

Thanks for that, will try! That being said, running -W fails as there appears as warnings from other sources that are treated as errors. For example,

generating gallery...
generating gallery for auto_tutorials... [  9%] 01_KalmanFilterTutorial.py
Warning, treated as error:

../tutorials/01_KalmanFilterTutorial.py unexpectedly failed to execute correctly:

    Traceback (most recent call last):
      File "/Users/chongzhenyuen/Documents/iib-project/stonesoup/docs/tutorials/01_KalmanFilterTutorial.py", line 192, in <module>
        plotter.plot_ground_truths(truth, [0, 2])
      File "/Users/chongzhenyuen/Documents/iib-project/stonesoup/stonesoup/plotter.py", line 2495, in plot_ground_truths
        self.fig.add_trace(go.Scatter(truth_kwargs))
      File "/Users/chongzhenyuen/miniforge3/envs/iib-project/lib/python3.10/site-packages/plotly/graph_objs/_scatter.py", line 3192, in __init__
        self._process_kwargs(**dict(arg, **kwargs))
      File "/Users/chongzhenyuen/miniforge3/envs/iib-project/lib/python3.10/site-packages/plotly/basedatatypes.py", line 4322, in _process_kwargs
        raise err
    ValueError: Invalid property specified for object of type plotly.graph_objs.Scatter: 'legendrank'

    Did you mean "legendgroup"?

Comment on lines +15 to +17
# 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]:
Copy link
Contributor

@nperree-dstl nperree-dstl Jan 3, 2025

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.

Suggested change
# 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants