Skip to main content

Stochastic Variational Inference for State Estimation

Accompanying code for "State estimation of a physical system with unknown governing equations" by Kevin Course and Prasanth B. Nair.

Example usage

Index

  1. Installation
  2. Usage
  3. Building documentation
  4. Reference

1. Installation

If you just want to use the package, you can install svise from PyPI.

If you wish to reproduce experiments / figures, we recommend installing optional dependencies.

Install from PyPI

pip install svise

The best place to learn about the package is the tutorials or the documentation

Installing Optional Dependencies

We use conda-lock and poetry to manage dependencies (although we wouldn't recommend it...).

After installing conda-lock, follow the steps below to install all dependencies used in the experiment environment.

  1. Clone the repository.
git clone https://github.com/coursekevin/svise.git
  1. Navigate into the directory and create a new conda environment.
conda-lock install --name svi-state-estimation conda-lock.yml
  1. Activate the environment that was just created.
conda activate svi-state-estimation
  1. Install the remaining dependencies.
poetry install --with dev
  1. Run tests to confirm everything was install correctly. (Some tests are stochastic so might fail on some attempts. If any tests fail, run again before filing an issue.)
pytest tests/

Dependencies:

  • see pyproject.toml for a complete list of dependencies.
  1. Download pretrained models, data, and figures:
repopacker download svise-pack.zip
repopacker unpack svise-pack.zip

This will download everything and place it into the correct directories except for the cylinder data used in the third example. The cylinder data is split up in seven 3.2GB chunks. Download all the chunks from Zenodo and combine the data with:

cat cylinder_data_split.z*[0..9]* cylinder_data_split.zip > cylinder_data.zip

Unzip the data move the file vortex.pkl into the directory

/experiments/3_cylinder_flow/data

2. Usage

Using the package

See the tutorials or the documentation.

Running numerical studies

The numerical studies can be rerun from the experiments directory using the command-line script main.py. All numerical studies follow the same basic structure: (i) generate datasets, (ii) train models / run methods, and (iii) post process for figures and tables.

  1. Generate dataset for a specific experiment. The newly generated dataset can be found in the experiment subdirectory.
python main.py [experiment] generate-data
  • Experiments in main text:

    • pure-se (state estimation without corruptions)
    • corrupted-se (state estimation without probabilistic corruptions)
    • cylinder-flow (Cylinder-flow reduced-order modeling experiment)
  • Examples in Methods:

    • symb-goveq-disc (discovering governing equation experiments)
    • second-order-disc (second order governing equation discovery)
    • ext-goveq-disc (Lorenz '96 experiment)
    • binary-black-hole (Binary black hole problem)
  1. Train a model on a dataset optionally specifying the random seed. The model will be saved in the experiment subdirectory. If there is only one dataset (such as is true for the cylinder-flow problem) there is no need to specify the dataset path.
python main.py [experiment] run-[method] -dp path/to/dataset.pt -rs seed
  • Methods:
    • svise (stochastic variational inference for state estimation)
    • pf (particle filter)
    • sindy (SINDy with STLSQ + SINDy with SR3)
  1. Post process results for figures and tables. Any figures or tables can be found in the experiment subdirectory. This script expects there to be one model / dataset. Undefined behavior may occur if this is not the case.
python main.py [experiment] post-process

3. Building documentation

Building documentation requires Sphinx and the Read the Docs Sphinx Theme. First navigate into the docs directory.

Building html docs:

make html

Building pdf docs:

make latexpdf

Completed docs can be found in the docs/_build directory.

4. Reference

Course, K., Nair, P.B. State estimation of a physical system with unknown governing equations. Nature 622, 261–267 (2023). https://doi.org/10.1038/s41586-023-06574-8

Metadata

Release files for svise 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for svise 0.1.4
File Size Uploaded Provenance
svise-0.1.4.tar.gz 141.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for svise 0.1.4
File Interpreter ABI Platform
svise-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 294.7 kB

Release files / svise-0.1.4.tar.gz

Download URL svise-0.1.4.tar.gz
Size 141.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3a5b2927e56a2feba8e56497870349b2b2cb44fc338c26f37c763130b82a9017
BLAKE2b-256 checksum
How to use checksums
b9052550b65170acb1420668b54b320fd307146bd8bade21c1ae48963ed43048
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.13 Darwin/23.5.0

Release files / svise-0.1.4-py3-none-any.whl

Download URL svise-0.1.4-py3-none-any.whl
Size 152.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65458c60ae0de51ef44f8f2f11e66749977fe7fa01f169a67905b5acb3827734
BLAKE2b-256 checksum
How to use checksums
30c46172036e635a87ac138df264cc741d2aff77a8ea460081c9eb53ce9faa92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.13 Darwin/23.5.0

Security for svise 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page