Hi,
When building a mixture, like the small example below, I noticed that the RV corresponding to the mixture are not accessible…!
The RV c1 & c2 are not in the trace output.
Calling trace['c1']
yield an error, same for c2.
I don’t understand why we can’t access them.
import numpy as np
import pymc3 as pm
data = np.random.normal(size=100)
with pm.Model() as model:
c1 = pm.Normal.dist(mu=0,sd=1)
c2 = pm.Normal.dist(mu=1,sd=1)
w = pm.Dirichlet('w',a=np.array([1,1]))
mix = pm.Mixture('mix',comp_dists=[c1,c2],w=w, observed=data)
trace = pm.sample()
This problem is getting even worse when I discovered that it’s not even accessible during the samping. I wanted to add a penalty to the c1 parameter using a Potential, with the following code :
import numpy as np
import pymc3 as pm
data = np.random.normal(size=100)
with pm.Model() as model:
c1 = pm.Normal.dist(mu=0,sd=1)
c2 = pm.Normal.dist(mu=1,sd=1)
p= pm.Potential('p',c1*c1) # added potential
w = pm.Dirichlet('w',a=np.array([1,1]))
mix = pm.Mixture('mix',comp_dists=[c1,c2],w=w, observed=data)
trace = pm.sample()
outputs this error message :
TypeError: unsupported operand type(s) for *: ‘Normal’ and ‘Normal’
(Note : The value used in the potential is a dummy one, it’s just to show that you can’t access c1 or c2 during sampling.)
I’d appreciate any help or link to documentation to better understand what happen here…