Deterministic Equation for p Always Results in 'nan'

I am trying to use the model:

with basic_model:

    # Priors for unknown model parameters
    beta = pm.Normal("beta", mu=0, sigma=1)
    gamma = pm.Normal("gamma", mu=0, sigma=1)

    # Expected value of outcome
    p = pm.Deterministic('p', beta/((beta-gamma))*(np.exp(time*(beta-gamma))-1)+1)
    observed = pm.Normal('obs', mu=p, sigma=100,observed=data)
    
    # Draw the specified number of samples
    trace = pm.sample();

When I run map_estimate on this, it shows that ‘p’ is full of ‘nan’ values. The issue seems to be with the equation within pm.Deterministic. Changing it to something simpler makes it work. Replacing np.exp with tt.exp did not help. Any idea what’s going on here?

Break your deterministic down into more basic operations, store each as a separate deterministic, look at which one of those contains Nans.

1 Like