0

In pymc3 how would I create a condition a switch statement around distributions?

""" If True, use mu1, else use mu2? """


with pm.Model() as model_lkj:
    category = pm.Categorical('category', p=[0.5, 0.5])
    # cat == 1:
    mu1 = pm.Normal(name='mu2', mu=5, sd=5)
    # else
    mu2 = pm.Normal(name='mu2', mu=4, sd=4)
Rob
  • 3,333
  • 5
  • 28
  • 71
  • as soon as I posted this, I realized I should probably look into `pm.math.switch`. Not sure if it's right yet so I'll leave this open – Rob Sep 26 '19 at 21:28
  • That's exactly right. Note that for more complicated models, you may want to marginalize out the discrete variables (`category` here) so that you can use NUTS. – colcarroll Sep 27 '19 at 19:49

0 Answers0