I tried to do what you said here
but cannot get it to work.
Here is a simple example of what I did
def test():
N = 1000
N2 = int(N//2)
# create test data sets
data = np.ones(N)
data[N2:] = 3.0
with pm.Model() as m1:
mu1 = pm.Normal('mu1', mu=0.0, sd=100.0)
err = pm.HalfCauchy('err1', beta=5.0)
w1 = np.zeros(N)
w1[N2:] = -1.0e10
p = pm.Potential('p1', shared(w1))
l1 = pm.Normal('lk1', mu=mu1, sd=err, observed=data)
advi = pm.ADVI()
approx = advi.fit(100000)
return approx
approx = test()
s = approx.sample(1000)
pm.summary(s)
Average Loss = 5e+12: 100%|██████████| 100000/100000 [00:43<00:00, 2300.78it/s]
Finished [100%]: Average Loss = 5e+12
mean sd mc_error hpd_2.5 hpd_97.5
mu1 2.003387 0.034653 0.001194 1.935714 2.069872
err1 0.999572 0.023656 0.000643 0.956357 1.047354
mu1 seems to be not affected by the potential at all.
What am I doing wrong?