price = pd.read_csv('C:\\Users\\mypath\\price.csv', index_col= [0,1], usecols=[0,5,6])
yt = price.loc['AUS']
yt = yt.pct_change().dropna().values
def p(u, sigma, pi):
d = pi / (2*np.pi*sigma)**0.5 * np.exp(-(yt-u)**2 / (2*sigma**2))
return d
def Lf(u, sigma, pi):
prob = p(u[0], sigma[0], pi[0]) + p(u[1], sigma[1], pi[1])
L = np.sum(-np.log(prob))
return L
pi_init = (0.5,0.5)
sigma_init = (0.1,0.1)
u_init = (0.1,0.1)
res = opt.minimize(Lf, (u_init, sigma_init, pi_init), method='L-BFGS-B')
如果我运行Lf(),我会得到一个真实的,但当我运行minimize时,我会得到以下错误消息:
TypeError:Lf()缺少2个必需的位置参数:“西格玛”和“圆周率”
这条信息对我来说没有意义...
1条答案
按热度按时间yyyllmsg1#
也许你可以这样打电话试试