Hello,
I had the same bug with the Metropolis sampler, which was solved by updating to v5.6.1.
Now i want to use SMC.
Here I simplified my problem as much as possible.
I want to sample a random walker that takes N steps, where each step has the length 1 and the angle phi is sample by an uniform dist. between 0 and 2*pi. Then i want to calc. the mean in each direction x and y, where x = cos(phi) and y=sin(phi).
As result, in 2d (with only one angel phi) I get a Gaussian dist. with mean=0, which i would expect.
Now adding a second angel theta to get a 3d version i get a bias in cos(phi) resulting in a bias in x, even when I don’t add cos(theta) to the scan function(see sample code below).
My Model in 2D, to add theta i include everything that is marked with a #
N=180
processors=4
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 _cp, _sp, prior: prior + [_cp, _sp],
sequences = [ cp, sp],
outputs_info = pt.tensor.zeros(2))
x = _x[:,0]
y = _x[:,1]
pm.Deterministic("cos_phi_mean", cp.mean())
pm.Deterministic("sin_phi_mean", sp.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())
pm.Potential("shidqww", (cp*0).sum())
datat = pm.smc.sample_smc(draws=5000,cores=processors)
Running this model with the NUTs sampler results in mean around 0.
I am fairly new to all this, so I am not quite sure where I should start to look at to solve this
I am currently running v5.11.0.
The script:
Smc_rand_2d.py (1.3 KB)