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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tycki-0.0.5.tar.gz.
File metadata
- Download URL: tycki-0.0.5.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.20 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74387cc6b3f6bf41209f9631e8b3be998c1e56e0d0ac7e9004b33a60609e512c
|
|
| MD5 |
47b12be0c1f5b013f111270de92a2042
|
|
| BLAKE2b-256 |
8b32fb3b636a2ee02225783cf0d9fdc3fe54257990759c438fb8b2a41385c5e3
|
File details
Details for the file tycki-0.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: tycki-0.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 407.9 kB
- Tags: CPython 3.12, 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.20 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67286dac68d9ec29ba1f92a23a8d4958f1345c22360e72a9b188ad6cc2c95505
|
|
| MD5 |
3501cc9178361e0852ee5cb6679de3d4
|
|
| BLAKE2b-256 |
2e041264e20762aaaacca278828b8f37a7d060e487064cea9bf57b0b617594f1
|
File details
Details for the file tycki-0.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: tycki-0.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 406.0 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.20 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4252b7bb05b26f6a1dd802f093b972b96809de548fc46a11d1e44d5382d2217d
|
|
| MD5 |
73d062dad23225de4924db15a79a7da6
|
|
| BLAKE2b-256 |
3b12cfb4ca120849b5df330283cd8a2a3db58e087dcb32e4f61884e3dab99bc7
|
File details
Details for the file tycki-0.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: tycki-0.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 405.0 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.20 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dbb20858f9346f94ded68bc999dc89d895c363d32430a9d01dd22fd85ed8196
|
|
| MD5 |
f095fd9f59c69b48113ed6ff92703898
|
|
| BLAKE2b-256 |
ce25f4585ea0451e8f33cadf5ff141ab6675adb211c3935ca85dd9314cbdbe21
|
File details
Details for the file tycki-0.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: tycki-0.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 405.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.20 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4972c8256f57a65e83d77d5f116ab2544f52661d566d5ab271d2022263b03cc
|
|
| MD5 |
21d1c5209253c3add3ee4ac46bfde269
|
|
| BLAKE2b-256 |
9eebeb1a002cf30403117849f73935adfa3d1aca2eca2ab0eea83d6350f14b75
|
File details
Details for the file tycki-0.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: tycki-0.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 405.3 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.20 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79d86a96b37f92f37be1ac2a83e3271775e776b3a3ed07102c32a97717ba2183
|
|
| MD5 |
26d8f86cd2af0554d968972878cd22c2
|
|
| BLAKE2b-256 |
4faa475b940e801bb1185f644cdcd3d2a72c66f8ef0f2fb110d2bfe1ccda76b5
|