Hi everyone,
I am using PyMC v5.26.1 to implement a Bayesian model using the Markov Chain Monte Carlo (MCMC) method. My model function, demc_diffuse_specular, uses the pm.DEMetropolisZ sampler.
I have run this model in two different environments and noticed a significant discrepancy in the inference results:
The mean residual between the model and the actual data for Python version 3.13 is 0.28, and for Python version 3.12 it is 0.01.
My Main Question
Given that the code is identical (including the use of random_seed=42 and the same DEMetropolisZ sampler configuration), is it possible that the Python version (3.12 vs. 3.13) is drastically affecting PyMC sampling, especially with pm.DEMetropolisZ?
Model Function Details
I am attaching the relevant code snippet for your review:
def demc_diffuse_specular(data, beta):
estmag = data[‘mag_per’].to_numpy()
r = data[‘r’].to_numpy()
phaseang = data[‘phi’].to_numpy()
phase_model = pm.Model(check_bounds=False)
with phase_model as fine_model:
# Priors (Uniform)
cross = pm.Uniform('cross', lower=0.0, upper=3.)
rho = pm.Uniform('rho', lower=0.0, upper=1.0)
# Likelihood
sigma = pm.HalfNormal("sigma", sigma=1.)
mu = diffuse_specular_function(r, phaseang, cross, rho, beta, 0.0)
Y_obs = pm.Normal('Y_obs', mu=mu, sigma=sigma, observed=estmag)
with fine_model:
# Sampler Configuration
step_demz = pm.DEMetropolisZ(scaling=0.01, tune_interval=100)
sample_model_demz = pm.sample(
draws=25000, tune=25000, chains=10,
step=step_demz, random_seed=42)
stati_results_demz = az.summary(sample_model_demz)
return sample_model_demz, stati_results_demz