pymc-devs / pymc

Bayesian Modeling and Probabilistic Programming in Python
https://docs.pymc.io/
Other
8.53k stars 1.98k forks source link

sample_posterior_predictive wrongly considers Deterministic variables as source of volatility #7183

Open ricardoV94 opened 5 months ago

ricardoV94 commented 5 months ago

Description

As shown in one of the new examples in #7014

import pymc as pm

with pm.Model() as model:
    x = pm.Normal("x")
    y = pm.Normal("y")
    det_xy = pm.Deterministic("det_xy", x + y ** 2)
    z = pm.Normal("z", det_xy)
    det_z = pm.Deterministic("det_z", pm.math.exp(z))
    obs = pm.Normal("obs", det_z, 1, observed=[20])

    idata = pm.sample(tune=10, draws=10, chains=2)

    pm.sample_posterior_predictive(idata, var_names=["det_xy", "det_z"])
    # Sampling: [z]