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.7.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.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

tycki-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

tycki-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

tycki-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

tycki-0.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: tycki-0.0.7.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for tycki-0.0.7.tar.gz
Algorithm Hash digest
SHA256 e82198abc590b367db808cd855e019fb08672b266ef510469f8c828cd9eb5ec7
MD5 d14915df67a71c4015ab67be7ba5bca9
BLAKE2b-256 ee0bc0d92338c065f4b6cf92347dc951dce048ffd26274cd11bdb23d127611fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 087e05b4740b94fe3afb25ec5a993df5686d04ba575270c1463af7899c5c1fb2
MD5 42ca07c4228b96b672d6b700226b5489
BLAKE2b-256 81f1214bd1e9aec474e34970eeb284ffd91a51912aa3d0028ba29c0697a15518

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 802b00b994ddd42a4e03766091734065f4d732e9f761beb743770f7e9792619e
MD5 4240b7cf37ce5346c40e4d24e3269eb5
BLAKE2b-256 fd767e7ff1843ebdcd1c8e18f0d28778acf1fcfd45847c0d195016613d73a583

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9499325176b51f9eac89f8902953b254b6ca23226057dda9c17fa56e8a5e386f
MD5 96c8a3d1fb48ef5c2c3b75307c311545
BLAKE2b-256 b0ecb1fbedbe6a4fb770f47e62cb31f0f1c4952622af73b7cdc2a143885ccbe0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 71e4db7dd78f9b4d1fba58914d8819384fef7960a71cf7f06e9049fe7711b257
MD5 bbd68ab1b23e326c55041bb8e4245f4c
BLAKE2b-256 87bc1fb88039017354a3d5aa8d17e1b0ea12fed6ee8374096e9a2fe26ef079c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 29f8d3eb5f2869ee6786cf9747ea21dad3d0a8f590b0470d3ff779120fd4e4e3
MD5 f71e2054fb9768b9dba5c14349a8f280
BLAKE2b-256 63c6942144ffb455378887ef6adfc6b45bc508c8f394370134852a982928eb77

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