TypeError:“ numpy.float64”对象不可调用;公式中的错误

时间:2019-04-15 13:28:09

标签: python numpy

我要编写公式,但出现以下错误:

TypeError: 'numpy.float64' object is not callable

公式为:

logL = len(eps)*(np.log(np.sqrt(OMEGA)) - np.log(beta(p,q)) + p*DELTA) +
    np.sum(p*np.sqrt(OMEGA)*eps/(np.sqrt(sigma_2))) -
    0.5*np.sum(np.log(sigma_2)) - 
    (p+q) * np.sum(np.log(1+np.exp(np.sqrt(OMEGA)*eps / (np.sqrt(sigma_2))) + DELTA))

使用以下功能:

def garch_filter(omega, alpha, beta, eps):
    iT = len(eps)
    sigma_2 = np.zeros(iT)

    for i in range(iT):
        if i==0:
            #sigma_2[i] = omega/(1-alpha-beta)
            sigma_2[i] = np.var(eps)
        else:
            sigma_2[i] = omega + alpha*eps[i-1]**2 + beta*sigma_2[i-1]
    return sigma_2

def OMEGAf(p,q):
    OMEGA = polygamma(1,p) + polygamma(1,q)

    return OMEGA

def DELTAf(p,q):
    DELTA = digamma(p) - digamma(q)  

    return DELTA

在代码中,*p之间的DELTA符号消失了,但是在那里。 我希望有人想要/可以帮助我。

0 个答案:

没有答案