Skip to main content

Taylor moment expansion in Python.

Project description

Taylor moment expansion (TME) in Python

Please see the documentation of the package in https://tme.readthedocs.io.

Install

Install via pip install tme or python setup.py install.

Examples

import tme.base_jax as tme
from jax import jit

# Define SDE coefficients.
alp = 1.
def drift(x):
    return jnp.array([x[1],
                      x[0] * (alp - x[0] ** 2) - x[1]])


def dispersion(x):
    return jnp.array([[0.],
                      [x[0]]])


# Jit the 3-order TME mean and cov approximation functions
@jit
def tme_m_cov(x, dt):
    return tme.mean_and_cov(x=x, dt=dt,
                            a=drift, b=dispersion, Qw=jnp.eye(1),
                            order=3)

# Compute E[X(t) | X(0)=x0]
x0 = jnp.array([0., -1])
t = 1.

m_t, cov_t = tme_m_cov(x0, t)

Inside folder examples, there are a few Jupyter notebooks showing how to use the TME method (in SymPy and JaX).

License

The GNU General Public License v3 or later

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

tme-0.1.0.tar.gz (11.0 kB view hashes)

Uploaded Source

Built Distribution

tme-0.1.0-py3-none-any.whl (9.3 kB view hashes)

Uploaded Python 3

Supported by

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