Bayesian Inference (BI) は Numpyro等のPythonパッケージの上に作られた、使いやすいインターフェースのパッケージ。R版、Julia版もある。
GPU対応しておりStanより早いのが売り
The Bayesian Inference library for Python R and Julia | bioRxiv
紹介論文。CPUでもStanより速いという実験結果がのっている
from BI import bi
# Setup device------------------------------------------------
m = bi(platform='cpu')
# Import Data & Data Manipulation ------------------------------------------------
# Import
from importlib.resources import files
data_path = m.load.howell1(only_path = True)
m.data(data_path, sep=';')
m.df = m.df[m.df.age > 18] # Subset data to adults
m.scale(['weight']) # NormalizeWARNING:2026-01-23 22:19:37,012:jax._src.xla_bridge:794: An NVIDIA GPU may be present on this machine, but a CUDA-enabled jaxlib is not installed. Falling back to cpu.
jax.local_device_count 20
Loading...
# Define model ------------------------------------------------
def model(weight, height):
a = m.dist.normal(178, 20, name = 'a')
b = m.dist.log_normal(0, 1, name = 'b')
s = m.dist.uniform(0, 50, name = 's')
m.dist.normal(a + b * weight , s, obs = height)
# Run mcmc ------------------------------------------------
m.fit(model) # Optimize model parameters through MCMC samplingsample: 100%|█| 1000/1000 [00:00<00:00, 1408.29it/s, 3 steps of size 7.80e-01. a
# Summary ------------------------------------------------
m.summary() # Get posterior distributionsarviz - WARNING - Shape validation failed: input_shape: (1, 500), minimum_shape: (chains=2, draws=4)
Loading...
- Sosa, S., Brooke McElreath, M., & Ross, C. (2026). The Bayesian Inference library for Python R and Julia. 10.64898/2026.01.19.700318