Dear pyro experts
I am not sure how to implement this.
I am trying to estimate with a 1D mixed normal distribution.
Following your tutorial, I was able to build the model as follows.
Def model(data):
Weights = pyro.sample(‘weights’, dust.Dirichlet(0.5*torch.ones(K)))
With pyro.plate(‘components’, M):
Locs = pyro.sample(‘locs’, dust.Normal(0., 10.))
Scale = pyro.sample(‘scale’, dust.LogNormal(0., 2.))
With pyro.plate(‘data’, N):
Assignment = pyro.sample(‘assignment’, dust.Categorical(Weights))
Pyro.sample(‘obs’, dust.Normal(locs[assignment], scale[assignment]), obs=data)
However, there are K data in one dimension, and running this code K times will take a long time.
Since the number of each data is the same N, we can consider it as N data in K dimensions.
So, I want to extend the above implementation to K dimensions, but it does not work. How should I implement this?
Def model(data):
With pyro.plate(‘dim’, K):
Weights = pyro.sample(‘weights’, dust.Dirichlet(0.5*torch.ones(K)))
With pyro.plate(‘components’, M):
Locs = pyro.sample(‘locs’, dust.Normal(0., 10.))
Scale = pyro.sample(‘scale’, dust.LogNormal(0., 2.))
With pyro.plate(‘data’, N):
Assignment = pyro.sample(‘assignment’, dust.Categorical(Weights))
Pyro.sample(‘obs’, dust.Normal(locs[assignment], scale[assignment]), obs=data)
Also, is it faster to do MCMC at the same time?
Furthermore, given that there is no correlation between the two, I think it can be implemented as a multivariate mixed normal distribution, but which is the correct implementation?