Skip to main content

Dynamic Bayesian Inference Package

Project description

DynaBayes

Dynamic Bayesian Inference for Coupled Phase Oscillators

This Python package implements a method for dynamic Bayesian inference of parameters in networks of coupled phase oscillators. It allows simulation and inference using a general model of phase interaction, including both direct phase coupling and coupling through phase differences.


📘 Model Formulation

The general form of the system implemented is:

$$ \frac{d\phi_i}{dt} = \omega_i(t) + \sum_{j=1}^{N} A_{ij}(t)\sin(\phi_j) + \sum_{j=1}^{N} B_{ij}(t)\sin(\phi_j - \phi_i) + \sqrt{E_{ii}} \xi_i(t) $$

Where:

  • $\phi_i$ is the phase of the $i$-th oscillator.
  • $\omega_i(t)$ is the intrinsic frequency (can be time-dependent).
  • $A_{ij}(t)$ controls influence from $\sin(\phi_j)$.
  • $B_{ij}(t)$ controls influence from phase differences $\sin(\phi_j - \phi_i)$.

Reference

This package is based on the dynamic Bayesian inference approach described in:

Stankovski, T., Ticcinelli, V., McClintock, P.V.E. & Stefanovska, A. (2014). A tutorial on time-evolving dynamical Bayesian inference. Eur. Phys. J. Special Topics 222, 2467–2485. https://doi.org/10.1140/epjst/e2014-02286-7

🔧 Installation

git clone https://github.com/p3dr0id/DynaBayes.git
cd DynaBayes
pip install -e .

⚡ Quick Example

The model used in the example below replicates Equation (10) from the paper

The system is:

$$ \frac{d\phi_1}{dt} = \omega_1(t) + a_1 \sin(\phi_1) + a_3(t) \sin(\phi_2) + \sqrt{E_{11}}\xi_1(t) $$

$$ \frac{d\phi_2}{dt} = \omega_2 + a_2 \sin(\phi_1) + a_4 \sin(\phi_2) + \sqrt{E_{22}}\xi_2(t) $$

Where:

  • $\omega_1(t) = 2 - 0.5 \sin(2\pi \cdot 0.00151 \cdot t)$
  • $a_3(t) = 0.8 - 0.3 \sin(2\pi \cdot 0.0012 \cdot t)$
  • $\omega_2 = 4.53$, $a_1 = 0.8$, $a_2 = 0.0$, $a_4 = 0.6$
  • $E_{11} = 0.03$, $E_{22} = 0.01$

import numpy as np
import dynabayes as db

# Define time-dependent parameters
omega = [lambda t: 2 - 0.5 * np.sin(2 * np.pi * 0.00151 * t), db.const(4.53)]
A = [
    [db.const(0.8), lambda t: 0.8 - 0.3 * np.sin(2 * np.pi * 0.0012 * t)],
    [db.const(0.0), db.const(0.6)]
]
B = [
    [db.const(0.0), db.const(0.0)],
    [db.const(0.0), db.const(0.0)]
]

# Simulate synthetic phase data
phi, true_funcs, t = db.simulate_model(omega, A, B, E=[0.03, 0.01], t_max=2000, dt=0.01)

# Run inference
params, centers = db.run_inference(phi, dt=0.01, E_true=[0.03, 0.01], pw=0.2, t=t)

# Plot parameter evolution
db.plot_parameters(params, true_funcs, centers)

# Show summary dataframe
db.show_summary(params, true_funcs, centers)

📈 Inference from External Phase Data

If you already have phase time series (e.g., from empirical data), you can apply inference directly:

# phi: 2D array of shape (n_oscillators, time_points)
params, centers = db.run_inference(phi, dt=0.01, E_true=[0.02, 0.01], pw=0.1, t=your_time_vector)

# You can still visualize even without a model:
db.plot_parameters(params, true_funcs=None, time_centers=centers)

Note: If true_funcs=None, only inferred parameters will be plotted.


🧪 Testing Models with 3+ Oscillators

You can define and simulate networks of 3 or more coupled oscillators by adjusting the size of omega, A, and B. The package automatically handles the dimensionality.


📄 License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dynabayes-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dynabayes-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file dynabayes-0.1.0.tar.gz.

File metadata

  • Download URL: dynabayes-0.1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for dynabayes-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e535305eec5a8c7f3e0662e33a000ecc71f6b778ec674ad55c4af3ba325eaca6
MD5 2ddf7163ff349058dc764bb9bd8e742a
BLAKE2b-256 cc23423100934268213e1c0e2eb86faa69a1230f6942284cf3d2be0b7f9aa159

See more details on using hashes here.

File details

Details for the file dynabayes-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dynabayes-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for dynabayes-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 415cf93a64cb35e40e1cd3bbfc83d2b1a1157909eb6f141ce40cf97c999da287
MD5 bc733f562214e29eaa413d5ca8e92a4d
BLAKE2b-256 c315742939b8debdb9a11a0ff6894c1e26ea851196ea7e98c59201fea24cc9a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page