# Discrepancy in PyMC (DEMetropolisZ) results between Python 3.12 and 3.13 (PyMC v5.26.1)

**URL:** <https://discourse.pymc.io/t/discrepancy-in-pymc-demetropolisz-results-between-python-3-12-and-3-13-pymc-v5-26-1/17438>\
**Category:** v5\
**Tags:** modeling\
**Created:** [November 12, 2025, 1:44pm UTC](https://discourse.pymc.io/t/discrepancy-in-pymc-demetropolisz-results-between-python-3-12-and-3-13-pymc-v5-26-1/17438 "2025-11-12T13:44:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/isa/32/9510_2.png) [@Isa](https://discourse.pymc.io/u/Isa)\
**Post date:** [November 12, 2025, 1:44pm UTC](https://discourse.pymc.io/t/discrepancy-in-pymc-demetropolisz-results-between-python-3-12-and-3-13-pymc-v5-26-1/17438/1 "2025-11-12T13:44:29Z")

</div>

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:

```auto
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

```

---

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [November 12, 2025, 4:21pm UTC](https://discourse.pymc.io/t/discrepancy-in-pymc-demetropolisz-results-between-python-3-12-and-3-13-pymc-v5-26-1/17438/2 "2025-11-12T16:21:09Z")

</div>

Is numpy / scipy version the same? That could affect the random seed
