I have a joint probability distribution that is defined like this:
import tensorflow as tf
import tensorflow_probability as tfp
tfd = tfp.distributions
def model():
s1 = yield tfd.JointDistributionCoroutine.Root(
tfd.Normal(3, 1, name='s1'))
s2 = yield tfd.JointDistributionCoroutine.Root(
tfd.Normal(0, 10, name='s2'))
c1 = yield tfd.Normal(s1 + s2, 1, name='c1')
c2 = yield tfd.Normal(s1 - s2, 2, name='c2')
f = yield tfd.Deterministic(tf.math.maximum(c1, c2), name='f')
joint = tfd.JointDistributionCoroutine(model)
joint.sample(10)
Now I want to marginalize it over the factor s2
but I'm not finding a good way of doing it. I found this on the documentation but I didn't understand how I would go about using this function. Any idea on how I could do such a thing?