Hello,
I try to sample different polymer-chains with length N in spherical-coordinates, and than calculate the center of mass in Cartesian coordinates. Theta and phi (angles between monomers) have a uniform prior distribution.
When running this with NUTS, I get a Gausian distribution for center of mass, with mean at 0. When i run this with Metropolis i get a Gausian, but for the x axis the mean is shifted. Seen in the plots below. I use 10 chains and 8000 draws. For me it looks like it converged(I am quite new to this). How can this happen, do I have a mistake in my parametrization?
(Using pymc 5.0.2)
My Model:
N=40
processors=10
with pm.Model() as chain:
theta = pm.Uniform("theta", lower=-np.pi/2, upper=np.pi/2, size=N)
phi = pm.Uniform("phi", lower=0, upper=2*np.pi, size=N)
ct = theta.cos()
st = theta.sin()
cp = phi.cos()
sp = phi.sin()
_x, _ = pt.scan(lambda _ct, _st, _cp, _sp, prior: prior + [_cp*_ct, _sp*_ct, _st],
sequences = [ct, st, cp, sp],
outputs_info = pt.tensor.zeros(3))
x = _x[:,0]
y = _x[:,1]
z = _x[:,2]
pm.Deterministic("z_mean", z.mean())
pm.Deterministic("x_mean", x.mean())
pm.Deterministic("y_mean", y.mean())
#This lets the energy-less distribution be uniform on the sphere
pm.Potential("sphere", ct.log().sum())
#step=[pm.step_methods.Metropolis([theta, phi])]
step=[pm.NUTS([theta, phi], target_accept=0.9)]
#datat = pm.smc.sample_smc(draws=500,cores=processors)
datat = pm.sample(draws = 2000, cores = processors, step= step)