Description
Someone reported a problem in Bambi when they used a HurdleGamma observation model (bambinos/bambi#951).
I figured out the dlogp was failing.
Here's an example in PyMC:
import pytensor
import numpy as np
import pymc as pm
n = 50
psi_true = 0.3
alpha_true = 2.0
beta_true = 1.5
dist = pm.HurdleGamma.dist(psi=psi_true, alpha=alpha_true, beta=beta_true)
y = pm.draw(dist, draws=n, random_seed=1)
with pm.Model() as model:
alpha = pm.HalfNormal("alpha", sigma=2.0)
beta = pm.HalfNormal("beta", sigma=2.0)
psi = pm.Beta("psi", alpha=2.0, beta=2.0)
y_obs = pm.HurdleGamma("y_obs", psi=psi, alpha=alpha, beta=beta, observed=y)
logp_fn = model.compile_logp()
dlogp_fn = model.compile_dlogp()
ip = model.initial_point()
print(ip)
print(logp_fn(ip))
print(dlogp_fn(ip))
print("\n")
ip2 = {'alpha_log__': np.array(.0), 'beta_log__': np.array(.0), 'psi_logodds__': np.array(.5)}
print(logp_fn(ip2))
print(dlogp_fn(ip2))
And this is the output
{'alpha_log__': array(0.69314718), 'beta_log__': array(0.69314718), 'psi_logodds__': array(0.)}
-51.17773249816925
[ nan -1.25171776 -11. ]
-59.52213360592764
[ nan 0.12414112 -17.61280388]
I'm using:
Python: 3.13.11
PyMC: 5.27.0
PyTensor: 2.36.3
Were you aware of recent changes that may have affected this?
Description
Someone reported a problem in Bambi when they used a
HurdleGammaobservation model (bambinos/bambi#951).I figured out the dlogp was failing.
Here's an example in PyMC:
And this is the output
{'alpha_log__': array(0.69314718), 'beta_log__': array(0.69314718), 'psi_logodds__': array(0.)} -51.17773249816925 [ nan -1.25171776 -11. ] -59.52213360592764 [ nan 0.12414112 -17.61280388]I'm using:
Were you aware of recent changes that may have affected this?