I’m new at numpyro, and I’m trying to sample the Fourier series parameters that fit my data. The likelihood function uses the misfit between a Fourier series model (curve) and the data at each iteration to discard model that have a misfit higher than 0.5.
This is how I parameterised the model: (Just for the record, this parametrization works perfectly on pymc)
def fold_bayesian_model(w, y=None):
c0 = numpyro.sample('c0', dist.Normal(0, 1),
)
c1 = numpyro.sample('c1', dist.Normal(0, 1),
)
c2 = numpyro.sample('c2', dist.Normal(0, 1),
)
wl = numpyro.sample('wl', dist.Normal(w, w/4))
# fourier parameters
theta = [c0, c1, c2, wl]
# function that calculate the misfit
misfitx = misfit(theta, fld, flr)
numpyro.sample('misfit', dist.Normal(0, 0.5), obs=misfitx)
kernel = BarkerMH(fold_bayesian_model)
mcmc = MCMC(kernel, num_warmup=3000, num_samples=1000)
rng_key = random.PRNGKey(64)
mcmc.run(rng_key, s0_lwmu, extra_fields=('potential_energy',))
Then I get the summary with r_hat and n_eff are weird:
mean std median 5.0% 95.0% n_eff r_hat
c0 1.04 0.00 1.04 1.04 1.04 6.48 1.07
c1 0.15 0.00 0.15 0.15 0.15 4.52 1.32
c2 -0.88 0.00 -0.88 -0.88 -0.88 4.61 1.14
wl -1.89 0.00 -1.89 -1.89 -1.89 267.23 1.00
wl is the wavelength of the Fourier series curve and seems weird, it should be around 14 000 m while I get -1.89.
Do you know why I get this weird results?
Thank you in advance