Skip to main content

Fast MCMC in Python

Project description

tycki

A simple Python tool for MCMC sampling using the amazing MCMClib.

Installation

tycki is on PyPI, so just

pip install tycki

Usage

tycki provides four samples from MCMClib:

  • Random-walk Metropolis-Hastings tycki.RWMH
  • Metropolis-adjusted Langevin algorithm tycki.MALA
  • Hamiltonian Monte Carlo tycki.HMC
  • No-U-Turn sampler tycki.NUTS

For sampling, the algorithms just require a start point, a log density function and - depending on the algorithm - the gradient of the log density function:

import tycki

rwmh = tycki.RWMH()
samples = rwmh.sample(log_density=lambda x: -(x**2).sum(), x0=[0, 0])

mala = tycki.MALA(x0=[0, 0]) # starting point can also be given in constructor
samples = mala.sample(log_density=lambda x: -(x**2).sum(), grad_log_density=lambda x: -2*x)

If you're too lazy to derive the gradient of your log density function manually, you can also use AD tools like jax:

import tycki
import jax
from jax import grad

@jax.jit
def logp(x, s=1):
        return -.5*(x**2 / s**2).sum()

rwmh = tycki.RWMH(x0=[0, 0])
samples = rwmh.sample(logp, grad(logp))

mala = tycki.MALA(x0=[0, 0])
samples = mala.sample(logp, grad(logp))

Licensing

This project is based on the amazing MCMClib by Keith O'Hara, licensed under the Apache License 2.0. Modifications and additions in order to make the by Richard D. Paul are licensed under MIT License.

See the LICENSE file for the full text of the 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

tycki-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (364.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

tycki-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (363.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

tycki-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (363.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

tycki-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (363.7 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file tycki-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tycki-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 364.9 kB
  • Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/6.6.0 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.28.2 rfc3986/1.5.0 tqdm/4.65.2 urllib3/1.26.13 CPython/3.10.12

File hashes

Hashes for tycki-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f8f569c96fc5ee32417928af9e1c238ca9e19329a165d0e2e61bd22da0ee4e36
MD5 530f70e88cef1650207e770b47f9257a
BLAKE2b-256 556c388dc99d94389c2a18109e49f1fb6dd6208a7a0f1f70eb73866493fdf336

See more details on using hashes here.

File details

Details for the file tycki-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tycki-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 363.4 kB
  • Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/6.6.0 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.28.2 rfc3986/1.5.0 tqdm/4.65.2 urllib3/1.26.13 CPython/3.10.12

File hashes

Hashes for tycki-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0ecaffbc5ee8b8c9c8885b19a5b466772814ac9c8a9145b7d0f9027f7f063d77
MD5 0bfddba9c5779a720213bf98a88afc60
BLAKE2b-256 0927e24e640f5ee7797fd57298606222f3670230bdc98a20da92a6ce459e4924

See more details on using hashes here.

File details

Details for the file tycki-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tycki-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 363.8 kB
  • Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/6.6.0 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.28.2 rfc3986/1.5.0 tqdm/4.65.2 urllib3/1.26.13 CPython/3.10.12

File hashes

Hashes for tycki-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 06bacbd49aeff9a2b657e6b66cca6942455d622a89a2b3fe8f1c9ae1a2f4d32b
MD5 7bbb440daf31d5a9a5f449753a2a08a7
BLAKE2b-256 e78b0d8efa6ffbbd5620d204a669fa1d766cc9488a93b6a0239f7f2c640f8277

See more details on using hashes here.

File details

Details for the file tycki-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tycki-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 363.7 kB
  • Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/6.6.0 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.28.2 rfc3986/1.5.0 tqdm/4.65.2 urllib3/1.26.13 CPython/3.10.12

File hashes

Hashes for tycki-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9e968bc50b61ab1cb7412cc13b576721b77a29cc6c612f257adada4a255363d
MD5 6254c313c9422ee27d34ae75f13155b9
BLAKE2b-256 d649386f2c84a72974375f6f5f2bb031a65e4dcc597aadf18cc12910f37c5238

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