Hi,
I think you are right. I added the normal Bernoulli likelihood with pm.Bernoulli and also added the weighted likelihood parts via pm.Potential. I should have used only the Potential likelihood. Thank you for pointing this out.
This would be the corrected example.
import numpy as np
import pymc3 as pm
import theano.tensor as T
N = 1000
P = 0.2
data = np.zeros(N)
data[:int(N * P)] = 1.0
weights = np.ones(N)
weights[:int(N * P)] = 4.0
with pm.Model() as model:
p_ = pm.Normal('p_',
mu=0.0,
sd=1000.0)
p = pm.Deterministic('p', pm.math.invlogit(p_))
pm.Potential('weights',
weights * pm.Bernoulli.dist(p=p).logp(data))
trace = pm.sample(10000, cores=1, random_seed=1)
trace['p'].mean() # 0.50019413
What do you think?