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.dev0.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.dev0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (373.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

tycki-0.0.3.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (371.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

tycki-0.0.3.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (372.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

tycki-0.0.3.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (371.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: tycki-0.0.3.dev0.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.dev0.tar.gz
Algorithm Hash digest
SHA256 24c472710b89da88a53999b7c4694e80da397e6e63c00b846156a0f31db6eb27
MD5 3f79b586ed341b963d28dd8622e4a551
BLAKE2b-256 8dfdac0be6f82eafd6207e553a9518908dc722f890022b06f51b7c41e39592d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tycki-0.0.3.dev0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 373.1 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.dev0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 544315e6cf94d45a81c414d90b273c08fddb2cfeebdd7ff5a0a08585dd4feef3
MD5 b8558c7170b36093c88dce291ead4a22
BLAKE2b-256 05454fec356c3262c67aae29449c7d20e2c54f24cdcec7463fcbf8cf8520589b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tycki-0.0.3.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 371.6 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.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8b0fc52ee9586002a9fce231841498c7d56eb1addbb00ca458e0c0c7121210a0
MD5 2ac368dc4a4daa349df308093a274e66
BLAKE2b-256 f9f26806e44e64f9cc228e5c4ef93d87a76b347977fb011546a4b2a7eb36cb71

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tycki-0.0.3.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 372.1 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.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 169168577aab0909b8ee3418a64eca51666c0f7db975252635b81a633f89148c
MD5 e800a005f01d083223318eff47a026cd
BLAKE2b-256 015066c264703e198530d0e38a69c6564cb3018c6d3a2641bd21f1e030ecc78a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tycki-0.0.3.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 371.0 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.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0949c6ac9dfd1b51c0fa6f60c79a2e1b359491ef288d317dbfa6b961479501ee
MD5 a7320ecc71ebf36b25202af9fba29453
BLAKE2b-256 b3bebf195449c2c4642c582c532457ec2def8f722f17241d169a76526331a244

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