Problem defining model multiplying gaussian and exponential

I’m new with pymc3, so I’ve only worked with simple gaussian likelihoods. I want to make a slightly more complicated posterior by multiplying a gaussian likelihood by a function which depends on a parameter “actha”. If that parameter is 1, I want the function to be an exponential, and if it is 0, I want the function to be 1-the exponential. The posterior is:

p({t_i},params|{vz_i},{actha_i}) = p({vz_i}|{t_i},params) p({actha_i}|{t_i},params)

(The total posterior is the multiplication of each component i)

Where p({vz_i}|{t_i},params) is a gaussian distribution and
p({actha_i}|{t_i},params) = exp(-t_i/t0) if actha == 1
1 - exp(-t_i/t0) if actha != 1
The parameters I’m trying to calculate are {t_i} that I have one for each of the N objects, and the hyper-parameters: params = t0, a_z and b_z, from a measured v_z_i, v_z_i_err and actha_i for each object.

Below is the code I’m using, but I’m getting that the likelihood is -inf:

with pm.Model() as model:
a_z = pm.Normal(“a_z”, mu=0.745, sigma=0.079, testval=0.745)
b_z = pm.Normal(“b_z”, mu=1.897, sigma=0.138, testval=1.897)

t = pm.Uniform("t", lower=0.1, 
                  upper=15, shape=N, testval=2)

t0 = pm.Uniform('t0',lower=0.1,upper=15,testval=3)

actha0 = pm.math.switch(actha==1,pm.math.exp(-t/t0),1-pm.math.exp(-t/t0))

vz0 = pm.Normal.dist(mu=0.0, sigma=pm.math.sqrt(v_z_err**2+sigma_vz(t,a_z,b_z)**2), shape=N)

like = pm.Mixture('like', w=actha0, comp_dists = vz0, observed=v_z)

My questions are:
-Is Mixture the best option for the problem I’m trying to solve?
-If it is, am I using the distribution in the correct way?

Thanks a lot!

Hi, it is a bit difficult to follow the post as is, can you format both math and code?

Discourse supports both code (either inline with a single backtick `, or block code with three backticks) and math (using latex notation between $ so that $t_i$ is rendered as t_i).

You should have also gotten a private message from discobot, answering and following it instructions aims to be a hands on tutorial for new users about the main Discourse features like these two.