Hi,
I’m trying to use PyMC to find the optimal parameters that describe some observed data, but it’s not working. I have two vectored parameters: X(x1,x2,xn) and V(v1,v2,…vn). I also have a pre-defined class that wraps a black-box function to take in X and V, returns simulated data d1, and it also contains the observed data d0.
def likelihood(X,V):
smod[0,2:] = X
smod[1,2:] = V
d1 = myBlackBox.calcD(smod)
d0 = myBlackBox.getObserved()
return (d1-d0)**2).sum()
with pm.Model as model:
X = pm.Normal('X', mu=X_pr, sd=100, shape=len(X_pr))
V = pm.Normal('V', mu=V_pr, sd=50, shape=len(V_pr))
like = pm.DensityDist('like', likelihood, observed=dict(X=X, V=V))
trace = pm.sample(10000)
This block of code is most-likely riddled with bugs, but I’m getting a ValueError with the first statement in the likelihood function. smod is global and ready contains some header information which is required by the blackbox function. So how do I map the values of X and V into smod so that it can be used to generate the simulated data? Also, are the statements correct within my pm.Model context manager? X and V are vectored parameters, with different mean values for their respective elements (i.e. mu=X_pr with X_pr also a vector). Can I use the pm.DensityDist in this manner?
Thanks!