Hi
I jumped into PyMC3 to model my problem, but I can’t seem to find enough resources for custom Likelihoods.
Roughly, I have N observed records X_i
X_i := (count_i, min_i, max_i)
The likelihood for each observation is a sum of sums of a reparametrized binomial distribution. In pseudo code:
def logp(count, min, max):
Li = 0
for i in range(N):
for s in range(1, min[i]):
for q in range(max[i], K):
Li = Li + theta**count[i] * theta**(q-s-count[i])
return Li
count = df.count.values
min = df.min.values
max = df.max.values
theta = Beta(..)
pm.DensityDist('x', logp, observed={'count': count, 'min':min, 'max': max})
This code is complaining that the min[i]/max[i] variables aren’t Integers but rather Tensor objects that I can not use in a loop. I tried to set datatypes but this didn’t solve the issue.
Can someone point me a to a similar custom likelihood function with loops?
Likewise, if I should not be thinking in terms of Loops but rather using tensors and masks, an example would be really welcome.