Python implementation of the No-U-Turn Sampler
Project description
jaxnuts
Python implementation of the No-U-Turn Sampler from Hoffman and Gelman (Algorithm 6) leveraging JAX.
Usage
Import libraries
import jax
import jax.numpy as jnp
import jax.random as random
from jaxnuts.sampler import NUTS
For low dimensional problems such as this simple example, force JAX to use the CPU (avoid GPU overhead)
jax.config.update('jax_platform_name', 'cpu')
Define a log-probability to sample from
def logprob(x):
"""Standard normal"""
return -.5 * jnp.dot(x, x)
Generate samples
key = random.PRNGkey(0)
sampler = NUTS(jnp.ones(2), logp=logprob, target_acceptance=.5, M_adapt=1000)
key, samples, step_size = sampler.sample(1000, key)
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 Distribution
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 jaxnuts-0.0.1.tar.gz.
File metadata
- Download URL: jaxnuts-0.0.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b3fd2f0271bf4643af115aa085c580e9dd6db608b87c06a60dbe29da6ff482c
|
|
| MD5 |
fc73019332d941cbb9f85cbe08346d7a
|
|
| BLAKE2b-256 |
f88a24ce3f4870701bf41b143259afcc06d6476dcee482c65049d7849b075da6
|
File details
Details for the file jaxnuts-0.0.1-py3-none-any.whl.
File metadata
- Download URL: jaxnuts-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de49e268bd79c3e519341e84f4836f761e5013288176ee42b062dcacc114a564
|
|
| MD5 |
41b481afa215bfe16ce17698587f9a4f
|
|
| BLAKE2b-256 |
29dbeb82b6a6b239507aedd9a8b4db35a6bab3e691664bfef1a43cf9853b7766
|