PyMC3 to PyMC: Alternative to check_parameters and bound?

Thank you. That worked perfectly. For posterity, this is my version of the logp from the notebook.

def logp(x, n, p):
    
    x_last = n - x.sum()
    
    # calculate the logp for the observations
    res = factln(n) + pt.sum(x * pt.log(p) - factln(x)) \
            + x_last * pt.log(1 - p.sum()) - factln(x_last)
    
    # ensure that the good conditions are met.
    good_conditions = pt.all(x >= 0) & pt.all(x <= n) & (pt.sum(x) <= n)
    res = pm.math.switch(good_conditions, res, -np.inf)

    return res
2 Likes