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.3.dev3.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.3.dev3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (372.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

tycki-0.0.3.dev3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (371.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

tycki-0.0.3.dev3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (371.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

tycki-0.0.3.dev3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (370.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file tycki-0.0.3.dev3.tar.gz.

File metadata

  • Download URL: tycki-0.0.3.dev3.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.3.dev3.tar.gz
Algorithm Hash digest
SHA256 a9b3d9a942b065f7f7585b9d01448e8c762f96421e6c13397a921e18dfcf6ae9
MD5 dc295deeb0610be6ec33f07c333c92b3
BLAKE2b-256 4ef55eaf946a0ae86ce8e4edaa74e48d0e5d49b98df3aef1751fd2a1f4582cd3

See more details on using hashes here.

File details

Details for the file tycki-0.0.3.dev3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tycki-0.0.3.dev3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 372.7 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.3.dev3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b3d4bcdac12cf310b3f6f66d72ae82f0903d046457aae6921eb794ea9b4ff729
MD5 6e43c92e30214f0a64ec58d540fb5e6f
BLAKE2b-256 dfe1137f105f507c87af98f30dd8b3cdf24eb1c6c972ecf9d49505699d42c942

See more details on using hashes here.

File details

Details for the file tycki-0.0.3.dev3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tycki-0.0.3.dev3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 371.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.3.dev3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d6cb50f14e08798ad031f2d9ab11eccc709ac4f3b7c3a3ad1bdce6b3e6034d1a
MD5 e4dafb2502ccef4a38fd65605bd817f3
BLAKE2b-256 759d66ebb38b65efe2c52d4fecd3afc820f49d0d1a854c1c4b49c9e59b4aa0f6

See more details on using hashes here.

File details

Details for the file tycki-0.0.3.dev3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tycki-0.0.3.dev3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 371.2 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.3.dev3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dfb250a1fcf682e85d0871ac17a7ddd45de28d217384979d5be3cb0695883f8d
MD5 8c996da677ec4247f9d53b1b85b21b98
BLAKE2b-256 d34f15eab24a76a29637ebe296329e377645d40d2bbabc9380f95be6adff6ca4

See more details on using hashes here.

File details

Details for the file tycki-0.0.3.dev3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tycki-0.0.3.dev3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 370.5 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.3.dev3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2c8c8e3ede4fce32088b9420d64514b1ae290bcd172de04f0608338df16c1270
MD5 a446cd32d576e3b8c284f598650a7a0d
BLAKE2b-256 ad8b3a4a77feb7ccceafd45bdf46fa8d90889eb7f9347fe250d039bb8159045b

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