我无法使用 ForwardDiff (Julia V.06) 获得多元函数的梯度,如下面的代码所示:
using ForwardDiff
function f1(c1::Real,c2::Real,k1::Real,k2::Real,z::Real,σ::Real;β=0.99,α=0.33,ρ=0.95,η=0.01,ϵ=Normal())
1/c1-(β*α*exp(ρ*z+σ*η*ϵ)*(k2/c2))
end
c1=0.388
c1=0.388
k1=0.188
k1=0.188
z=0.
σ=0.
g=(c1,c2,k1,k2,z,σ)->ForwardDiff.gradient(f1,(c1,c2,k1,k2,z,σ))
g([c1,c2,k1,k2,z,σ])
错误消息如下: MethodError: no method matching (::##25#26)(::Array{Float64,1}) 最接近的候选是:#25(::Any, ::Any, ::Any, ::Any, ::Any, ::Any) at In[15]:15 请问,我的代码中是否有遗漏或错误?