Adaptive Markov Chain Monte Carlo (MCMC) algorithms
Project description
Adaptive-MCMC
Adaptive Markov Chain Monte Carlo (MCMC) algorithms
Install
pip install adaptive-mcmc
Examples
import numpy as np
from adaptive_mcmc.mala import ESJDMALA
from scipy.stats import multivariate_normal
dim = 20
cov = 0.5 * np.eye(dim) + 0.5
inv_cov = np.linalg.inv(cov)
def logp(x):
return multivariate_normal.logpdf(x, mean=np.zeros(dim), cov=cov)
def grad_logp(x):
return -inv_cov @ x
mala = ESJDMALA(logp, grad_logp, initial_sample=np.zeros(dim), eps0=0.5)
samples, acc, eps_hist, esjd_hist = mala.run(20_000)
print(f"Acceptance: {acc:.3f}, Final epsilon = {eps_hist[-1]:.4f}")
pmala = PrecondESJDMALA(logp, grad_logp, initial_sample=np.zeros(dim), initial_covariance=np.eye(dim), eps0=0.5)
samples, acc, eps_hist, esjd_hist = pmala.run(20_000)
print(f"Acceptance: {acc:.3f}, Final epsilon = {eps_hist[-1]:.4f}")
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
adaptive_mcmc-0.1.3.tar.gz
(6.2 kB
view details)
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 adaptive_mcmc-0.1.3.tar.gz.
File metadata
- Download URL: adaptive_mcmc-0.1.3.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b022fd8e83e4b812368c135673abc1ab0d98b844ffcb32309772eb744c19d34f
|
|
| MD5 |
cfdadeb852a50fb8d10ca752cb17010a
|
|
| BLAKE2b-256 |
682ab812393917a483c2b8e23dffa1219869edb5377dba321e3ba45b5decd52a
|
File details
Details for the file adaptive_mcmc-0.1.3-py3-none-any.whl.
File metadata
- Download URL: adaptive_mcmc-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0a040710aa59825d124663ed9ab010b7a9fe9c07e50f3c5e704728feaa71254
|
|
| MD5 |
88675fd14671b4818ee5951cb1f33e20
|
|
| BLAKE2b-256 |
9a5d27e20170c6bce08b935ad3acd6f79c2f655defaed5811adda7eed6953abd
|