Question About Custom Distribution : the Generalized Poisson

That you for your reply!

To mimic the GeneralizedPoisson code, I changed gammaln to factln and log(pow()) to logpow in the above code. As a result, the error no longer occurs.

The gammln or log(pow()) function was probably being evaluated with too high values returning inf.

from pymc.distributions.dist_math import check_parameters, factln, logpow

def _generalized_poisson_logp(value, theta, lam):
    theta_lam_value = theta + lam * value
    log_prob = pt.log(theta) + logpow(theta_lam_value, value - 1) - theta_lam_value - factln(value)
    
    #log_prob = pt.switch(pt.le(theta_lam_value, 0), -np.inf, log_prob)
    
    log_prob = pt.switch(
        pt.or_(
            theta_lam_value < 0,
            value < 0,
        ),
        -np.inf,
        log_prob,
    )
    
    return check_parameters(log_prob, value >= 0, theta > 0, pt.abs(lam) <= 1, -theta / 4 <= lam)