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.6.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.6-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.6-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.6-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.6-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.6-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.6.tar.gz.

File metadata

  • Download URL: tycki-0.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 372af652189c40c8c68e10e9ac7064a37bff4ba112999c682e20d16931005159
MD5 d2e8f59e2122c796500b1d2701f99931
BLAKE2b-256 744c85f5d834c467654bafeea8a305d87e0a0d34a608390643c55b1fa904a778

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d64caf79b3f726d0e2b894eace7ecc2ebcddd1588af039c7da892f00a3c53a8b
MD5 027f39f387e55b0d79480af457d45cf3
BLAKE2b-256 8ee5fe0e8861d8ead757c890c46e7e652124bcfd00914ef304d69eccf2cc1ba4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a7da2cfdd245e314ca4c84533b2a867b3335077b1e6adeb49841e175def8b565
MD5 484a06a260b15a5ec63308777e99dda0
BLAKE2b-256 8cb1f5c95eb12f2d2a3fdf13c82c8a6584742a50d716f82233d29b6fb77c6201

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 55663bb4df410d1b71e81929327eb27ade2ee4196d4e5d5562b7baa615001927
MD5 06a74d991ae60dddb42e9ad85802e54a
BLAKE2b-256 370a8aa3a8044fda4925e9544722f68a3e8b14d07c8371a02c117b5aa22b8213

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e9bda9d55a0f18ee63c11e95f16c915741d295044d94caac699d1b10aa638fea
MD5 cd28649a4800dbf13c3b60c0a1ef89a3
BLAKE2b-256 975863cc55e4b6e6be6651de149b4d5e4a48b9715ce12a1f7c5689458067420d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8590656847c84549bbc0b1a5c3788db3e2b7d957c4e80b2264146a87b0bb922d
MD5 70f3769e53c7db66019cad3c7f5c81a1
BLAKE2b-256 378275136f35f920f4ff456b0559f070f4eb12dc103c3fd941019c756c500c44

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