CmdStanPy pattern
from cmdstanpy import CmdStanModel
model = CmdStanModel(stan_file="model.stan")
fit = model.sample(data=data, chains=4, parallel_chains=4, seed=123)
fit.summary()CmdStanPy is the preferred Python replacement for the book’s Stan/RStan examples because it keeps the model block readable and separates statistical modeling from sampler plumbing.