I am trying to define a mixture of bounded random variables e.g.
with pm.Model() as model:
w = w = pm.Dirichlet("w", a=np.ones(3))
upper_sig = pm.HalfNormal("upper_sig", sigma=0.2)
lower_sig = pm.HalfNormal("lower_sig", sigma=0.2)
efficiencies = pm.Mixture(
pm.Bound(pm.Normal, lower=1.0).dist(mu=1.0, sigma=upper_sig),
pm.Bound(pm.Normal, lower=0.0, upper=1.0).dist(mu=1.0, sigma=lower_sig),
but I am getting the following error:
TypeError: __new__() missing 1 required positional argument: 'dist'
Issue seems related to Using a bounded variable within a Mixture - Questions - PyMC Discourse - however, in the discussion it was mentioned the approach wouldn’t work for latest version of the code.
Ok, looks like the dists need to be constructed like this:
pm.Bound.dist(pm.Normal.dist(mu=1.0, sigma=upper_sig), lower=1.0),
pm.Bound.dist(pm.Normal.dist(mu=1.0, sigma=lower_sig), lower=0.0, upper=1.0),
I would suggest you use
pm.Truncated instead. That way you can also perform prior and posterior predictive sampling with the Mixture model.
Perfect, I could see
Bound was broken for the prior and posterior sampling, but that
Censored was broken for sampling!
Truncated works as you suggest.
Broken is perhaps a strong word They are different objects
Anyway glad I could help
Apologies, totally agree - just my naive understanding of the classes!