Trying to sample the Vanderplas model from the docs

This used to work in 3.1, but has stopped working, so I am a bit confused. Get a Nan energy error with NUTS and a trace which never moves with Metropolis. Any thoughts why this might be happening? Code below:

np.random.seed(42)
theta_true = (25, 0.5)
xdata = 100 * np.random.random(20)
ydata = theta_true[0] + theta_true[1] * xdata
# add scatter to points
xdata = np.random.normal(xdata, 10)
ydata = np.random.normal(ydata, 10)
import theano.tensor as T

with pm.Model() as model1:
    alpha = pm.Uniform('intercept', -100, 100)

    # Create custom densities, you must supply logp
    beta = pm.DensityDist('beta', lambda value: -1.5 * T.log(1 + value**2), testval=10)
    eps = pm.DensityDist('eps', lambda value: -T.log(T.abs_(value)), testval=10)

    # Create likelihood
    like = pm.Normal('y_est', mu=alpha + beta * xdata, sd=eps, observed=ydata)
with model1:
    #stepper=pm.Metropolis()
    #tracem1 = pm.sample(40000, step=stepper, njobs=1)
    tracem1 = pm.sample(4000)

Was able to fix it seemingly using a Normal prior on intercept than a uniform. My confusion remains…logp on the uniform should be 0 not nan, isnt it?

Seems the float type is not reinforce within Uniform (which is weird as I thought we fixed it).
change to the following line should fix it:

alpha = pm.Uniform('intercept', -100., 100.)

Thanks! Should i file an issue?

I just pushed a fixed :wink: Should work fine now if you update to master.