Git Product home page Git Product logo

bayesian-mechanics-sdes's Introduction

Bayesian mechanics for stationary processes

Companion repository for Bayesian mechanics for stationary processes (2021) by Lancelot Da Costa, Karl Friston, Conor Heins, and Grigorios A. Pavliotis. [Paper]

Installation

To run the code in this repo, we recommend building a conda environment using the provided environment.yml file, which will install (most of) the required dependencies for you - see below:

conda env create -f environment.yml

Once you build the repository using the environment file, you can activate it using:

conda activate bayesmech_statproc

In our experience installing jax with pip works better than going through conda. Therefore, after building the conda environment, use pip to install jax and jaxlib using the following:

pip install --upgrade jax jaxlib

Requirements

The requirements to run the code in this package are self-contained as dependencies in the environment.yml file (besides jax, see above). The core functionality depends on Python 3.8^ and relies heavily on the following packages for stochastic integration, statistics, and visualization routines:

Running the code

Once you've created and activated your conda environment with conda activate bayesmech_statproc, you can run the code to create the paper's figures using the general format:

python3 src/<SCRIPT_NAME>.py [-optional args...]

For example, to run the code that generates the Bayesian mechanics figures derived from the 3-D Ornstein-Uhlenbeck process (Figure 6), run the following line from a terminal window or other command line interface:

python3 src/linear_diffusion_3d.py 

or

python3 src/linear_diffusion_3d.py  --seed <SOME_INTEGER> --[save/nosave]

The optional command line argument --seed or -s can be used to specify a particular, fixed key for initializing jax's PRNG or pseudo-random number generation, which ensures reproducible initial system parameterisations and stochastic sample paths. If you don't enter a --seed argument, a default initialization key (the same one used to generate the figures from the paper) will be used instead. Therfore even in the absence of a user-given --seed argument, the script will reproduce the same figures upon repeated runs.

If you want to save the figures as .pngs to disk (in the ./figures folder), you can specify either --save or --nosave as a final keyword argument to your line (default is --save), e.g.

python3 src/linear_diffusion_6d_actinf.py  --save

NOTE: There is an exception to this general format for reproducing Figure 2 of the paper (the synchronization map example vs. non-example). There one should simply run:

python3 src/Sync_map_example.py

or

python3 src/Sync_map_non_example.py

to generate the left and right panels (respectively) of Figure 2.

bayesian-mechanics-sdes's People

Contributors

conorheins avatar lancelotdacosta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.