I’m new to Pyro. Trying to find an MCMC sample of the true posterior of the following problem:
The likelihood / Simulator / model - needs to sample 4 samples from this multivariate normal distribution.
Is there a way to specify this in pyro?
1 workaround that I did is expand the MVN from 2 to 8 dimensions, but this code throws an error and won’t run:
def model(obs):
theta = pyro.sample("theta", dist.Uniform(lower*torch.ones(dim), high=upper*torch.ones(dim)))
mu = theta[:2].repeat(1,4)
s1 = theta[2]**2
s2 = theta[3]**2
r = torch.tanh(theta[4])
S = torch.tensor([[s1**2, r*s1*s2],[r*s1*s2, s2**2]])
Sigma = torch.block_diag(S,S,S,S)
return pyro.sample("obs", dist.MultivariateNormal(mu[0,], S), obs=obs)
nuts_kernel = NUTS(model)
mcmc = MCMC(
nuts_kernel,
num_samples=1000,
warmup_steps=1000,
num_chains=1,
)
mcmc.run(x_obs)
UPDATE: Ok found the error - I didn’t change the S to Sigma in the distribution…
Still I wonder if there’s a way to do this without the workaround?