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 Distribution

tycki-0.0.4.tar.gz (3.8 MB view details)

Uploaded Source

Built Distributions

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

tycki-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (394.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

tycki-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (395.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

tycki-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (394.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

tycki-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (394.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

tycki-0.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (394.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file tycki-0.0.4.tar.gz.

File metadata

  • Download URL: tycki-0.0.4.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • 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.4.tar.gz
Algorithm Hash digest
SHA256 91dc8d6a86fd2c650f0a444311421e15ddd757afc42abfc7d554857260ce9410
MD5 d52adfae2de34db7c4f74e00c44385c1
BLAKE2b-256 0e9e627717e7c838d0fd2c5b6c9894ad12e0bb3fc5ae4312946597b2c2a45906

See more details on using hashes here.

File details

Details for the file tycki-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tycki-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 394.7 kB
  • Tags: CPython 3.12, 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.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d898b456758c5c13040bd6f6759255360b1bc0e23af630c39ac84fb912d18b20
MD5 38461ada579883001bc19dd7f67a0d19
BLAKE2b-256 fd5ffa18a5705f7093ca3c68fdd648f9cc3ee73cc6332f9f59a51a177699c9e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tycki-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 395.5 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.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab9c0f0faa077715836e6be66f5df1d3aca004852030f28af564b76b63bee29c
MD5 5becdfa8610ab8eadc46eff653ad9850
BLAKE2b-256 f5a1fa87242941f8fd09ab23bfdbb4a560af78c11be7f9956bdab535c6837b5a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tycki-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 394.3 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.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff91fed2aee55a3f90ead3a50cab3cd182871351892ccae9a1116921a4714732
MD5 834cde60d1b3ff48ba60d9eb4205fcf0
BLAKE2b-256 0b5697f58a500bf30e3c96f771860c59b22169def52b101a0c7efc33490d7ae7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tycki-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 394.5 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.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d09c092b7450de565aacb793084e0dfce87f341448fa78832e2536a51b8e861f
MD5 05a049fbb16d5427bdffae24b28372e6
BLAKE2b-256 ed9a33d7fe74ad1739b0f5e3377690ba1dab3d2ee0afe5fe333b4879e177d1e1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tycki-0.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 394.1 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.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b7a3daf9dd15fe6e5f39dd1a47082cb63d4400436c287e90ac940d2b5dfd14b1
MD5 6efa2bd38e22d6fe87733d9e5d3b49ab
BLAKE2b-256 8924d105a47d98fcc1fe63a9f55910e8d4943db7cd88993bc37133e503b126a5

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