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.2.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.2.tar.gz.
File metadata
- Download URL: adaptive_mcmc-0.1.2.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 |
414f41ef30836ea62f4aa15fcaa90a505e758d618d26a2b0b835ac7e0fba974f
|
|
| MD5 |
1a7cf5aa802c49e2e5c59130ed92ea0c
|
|
| BLAKE2b-256 |
967ab50b258e0b5376ab49a7a58da5c3e97914593a216806e5e52abe1a5d5ae9
|
File details
Details for the file adaptive_mcmc-0.1.2-py3-none-any.whl.
File metadata
- Download URL: adaptive_mcmc-0.1.2-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 |
73dce830f80f284018aab3555d7ba26450d7827294044db7b7c1bbae7d4e3238
|
|
| MD5 |
d081b10fb064e6e89f81b19ee523c62c
|
|
| BLAKE2b-256 |
a459e0d3f27aca67f4215438abb3ec67d914f99fb47b02480fa9918be6f99ae0
|