tme


Nametme JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryTaylor moment expansion in Python
upload_time2024-11-26 13:29:11
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseTaylor moment expansion (TME) in Python Copyright (C) 2021 Zheng Zhao This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
keywords markov models stochastic differential equations statistics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```python
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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tme",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "Markov models, stochastic differential equations, statistics",
    "author": null,
    "author_email": "Zheng Zhao <zz@zabemon.com>",
    "download_url": "https://files.pythonhosted.org/packages/f7/a7/75afd80d0757bf370fb7591351842874a9223ff7b9f096966c8179d0880b/tme-0.2.0.tar.gz",
    "platform": null,
    "description": "# Taylor moment expansion (TME) in Python\n\nPlease see the documentation of the package in https://tme.readthedocs.io.\n\n# Install\n\nInstall via `pip install tme` or `python setup.py install` (Please note that if you would like to use JaX, please\ninstall `jax` by yourself beforehand).\n\n# Examples\n\n```python\nimport tme.base_jax as tme\nimport jax.numpy as jnp\nfrom jax import jit, vmap\n\n# Define SDE coefficients.\nalp = 1.\n\n\ndef drift(x):\n    return jnp.array([x[1],\n                      x[0] * (alp - x[0] ** 2) - x[1]])\n\n\ndef dispersion(x):\n    return jnp.array([0, x[0]])\n\n\n# Jit the 3-order TME mean and cov approximation functions\n@jit\ndef tme_m_cov(x, dt):\n    return tme.mean_and_cov(x, dt, drift, dispersion, order=3)\n\n\n# Compute E[X(t) | X(0)=x0]\nx0 = jnp.array([0., -1])\nts = jnp.array([0.25, 0.5, 1.])\n\nm_t, cov_t = vmap(tme_m_cov, in_axes=[None, 0])(x0, ts)\n```\n\nInside folder `examples`, there are a few Jupyter notebooks showing how to use the TME method (in SymPy and JaX).\n\n# License\n\nThe GNU General Public License v3 or later\n",
    "bugtrack_url": null,
    "license": "Taylor moment expansion (TME) in Python Copyright (C) 2021 Zheng Zhao  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.  You should have received a copy of the GNU General Public License along with this program.  If not, see <https://www.gnu.org/licenses/>. ",
    "summary": "Taylor moment expansion in Python",
    "version": "0.2.0",
    "project_urls": {
        "documentation": "https://tme.readthedocs.io",
        "homepage": "https://github.com/zgbkdlm/tme",
        "repository": "https://github.com/zgbkdlm/tme"
    },
    "split_keywords": [
        "markov models",
        " stochastic differential equations",
        " statistics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5463bc6e246d26a3b1f9bf2d333da2c5488de3abfe4c2a2f632b7c291f6a7938",
                "md5": "51ef9eb252ed9e55d37c1faa95632d0a",
                "sha256": "bb486924edbfd4dbc37e8fbe511363996c631a96107fa255cdcb2f875b88e104"
            },
            "downloads": -1,
            "filename": "tme-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "51ef9eb252ed9e55d37c1faa95632d0a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10749,
            "upload_time": "2024-11-26T13:29:10",
            "upload_time_iso_8601": "2024-11-26T13:29:10.341073Z",
            "url": "https://files.pythonhosted.org/packages/54/63/bc6e246d26a3b1f9bf2d333da2c5488de3abfe4c2a2f632b7c291f6a7938/tme-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f7a775afd80d0757bf370fb7591351842874a9223ff7b9f096966c8179d0880b",
                "md5": "b3ed47f3102875819f2b9fdf554d2dcf",
                "sha256": "7c804ba47684106d96295b4e8f583d78d56d77a98577c906bf5a14f65c4453ee"
            },
            "downloads": -1,
            "filename": "tme-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b3ed47f3102875819f2b9fdf554d2dcf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 12314,
            "upload_time": "2024-11-26T13:29:11",
            "upload_time_iso_8601": "2024-11-26T13:29:11.877677Z",
            "url": "https://files.pythonhosted.org/packages/f7/a7/75afd80d0757bf370fb7591351842874a9223ff7b9f096966c8179d0880b/tme-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-26 13:29:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zgbkdlm",
    "github_project": "tme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tme"
}
        
Elapsed time: 1.63373s