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.8.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.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (447.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

tycki-0.0.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (444.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

tycki-0.0.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (443.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

tycki-0.0.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (442.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

tycki-0.0.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (442.9 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: tycki-0.0.8.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.8.tar.gz
Algorithm Hash digest
SHA256 37159aa979b3453d691d3d38376308efd51c8432019534706ce8efe8075dbb1d
MD5 805ba270374c289fbf47315df38223ef
BLAKE2b-256 f88138c47f54c59baeb7b2418b792d91447b7e517c7e276a41cf3c42fdbc4eb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ebd07a7b025939123b678d2e92755356837c7740ac4c777a5043804adfcb030c
MD5 36e790b3f40c041c2c72b3b4c7b22788
BLAKE2b-256 4ead5e99cf52073be3c5d0d900f0df8e33afed9d5cd746156373815510387196

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b0b9ab659a0682c4f114a08f6dd70ada98d99a8f6ecfb0265622338421ea003
MD5 b61a4360e21d6d808f61372428c47ea7
BLAKE2b-256 9fd386eba85620773c65001f78183fec563fe491b72afbbd7cffa265e9b4d029

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ceabaf4a04faa96091e869c5fc53da81515ea58211fa251007a8db7be727f600
MD5 7581a828b907c37d0e00c0f2c51fddef
BLAKE2b-256 019a9f0f2a805e8f496d4bbb1ec90854490c20e37fa638d30d34a9340dfe6ad7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e5f5012989167282aa5f15bfb71e3f8c19b5ad4ff04a34ef4a44211c277b967b
MD5 40d82691309ccb37afb815ceac394148
BLAKE2b-256 79c494c600bf68074a62f2457c73657a1033ca809dc546d1df5d80ecf704ddf5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tycki-0.0.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6332430c7c1e8ce6b10880f4d9a1644f801aa27b0336215f95c6765180c5009f
MD5 5e273e4f79db39f27a5a23165764ecf4
BLAKE2b-256 b0c3cd55970737c45079cb3f477353ab8521ecda67b9e00f7b3575316324f4ac

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