我不知道是否有人熟悉danforemanmackley的“emcee”Python模块,但我正在使用它来示例一个发行版。我使用平行回火采样器,因为我的分布是时髦的外观。以下是相关代码:
from emcee import PTSampler
rendim = 6
renwalkers = 100
ntemps = 20
gauss2 = PTSampler(ntemps, renwalkers, rendim, lnlike, lnprior)
p0 = [[[np.random.rand()*0.24,np.random.rand()*3,np.random.rand()*1,np.random.rand()*1,np.random.rand()*3,np.random.rand()*1] for i in range(renwalkers)] for i in range(ntemps)]
for q, lnprob, lnlike in gauss2.sample(p0,iterations=1000):
pass
gauss2.reset()
for q, lnprob, lnlike in gauss2.sample(p, lnprob0=lnprob,
lnlike0=lnlike,
iterations=10000, thin=10):
pass
我一直收到的错误是'努比·恩达雷'对象不可调用。以下是完整的错误:
^{pr2}$更新:以下是lnlike和lnprior函数:
def lnprior(theta):
eta, mu1, sig1, h, mu2, sig2 = theta
if 0 < eta < 0.24 and 0 < mu1 < 1.5 and 0 < sig1 < 1 and 0 < h < 1 and 0 < mu2 < 1.5 and 0 < sig2 < 1:
return 0
return -np.inf
def lnlike(theta):
eta, mu1, sig1, h, mu2, sig2 = theta
return -k*np.log(Nsamp)+np.sum(np.log(np.sum(MCetadist(eta,events,mu1,sig1,h,mu2,sig2),axis=1)))
消息“TypeError:”努比·恩达雷“对象不可调用”意味着努比·恩达雷“您试图作为函数调用的是一个模块或变量,因此不可调用。使用“()”调用非函数时,将出现此类型错误。你可以在引用后去掉“()”就可以了。在
相关问题 更多 >
编程相关推荐