How to define a custom likelihood on a bounded support (on a simplex)

A simple example goes like this:

with pm.Model() as m:
    pm.Normal(
        'x', 0., 1., shape=3, 
        testval=[0.5, .25, .25], 
        transform=pm.distributions.transforms.stick_breaking
#         transform=pm.distributions.transforms.sum_to_1
             )
    trace = pm.sample()
    
np.testing.assert_almost_equal(trace['x'].sum(axis=1), np.ones(len(trace['x'])))

I would not truncated it for now, as you are doing transformation already and I am not sure exactly how that would interact with simplex-like transformation. However, if you want to also truncated it, it’s also possible by using a chain transformation linking the sum_to_1 with a interval transformation.

Also, since you are working with HMM, make sure you check out this post: