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
(Please note that if you would like to use JaX, please
install jax
by yourself beforehand).
Examples
import tme.base_jax as tme
import jax.numpy as jnp
from jax import jit, vmap
# 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, dt, drift, dispersion, order=3)
# Compute E[X(t) | X(0)=x0]
x0 = jnp.array([0., -1])
ts = jnp.array([0.25, 0.5, 1.])
m_t, cov_t = vmap(tme_m_cov, in_axes=[None, 0])(x0, ts)
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.5.tar.gz
(10.5 kB
view details)
Built Distribution
tme-0.1.5-py3-none-any.whl
(8.8 kB
view details)
File details
Details for the file tme-0.1.5.tar.gz
.
File metadata
- Download URL: tme-0.1.5.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a4164bb5397e0e60927bef6de5e7b4f172a64c7d26ce1e53a151621f2087a2f |
|
MD5 | 26ed06c359e5b84987fcb799c62a0a77 |
|
BLAKE2b-256 | 1ffc0edb3245d645477467eff02a940dd2f43f32118d174e01b66e86f1f34700 |
File details
Details for the file tme-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: tme-0.1.5-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9fd207348ad195639e193b190d05336b3403ae8dda472042a7700d74eb4c75c |
|
MD5 | e729ad3d32fbb5a04b53d4f06461ebe9 |
|
BLAKE2b-256 | 1d1a8d54ab9e342d6313ec2122fbc65b48ab2c39723466c3b38588f26b9d3dc1 |