Im对期权价格进行建模,并对每个期权合约,使用Heston模型对基础资产的价格进行模拟。为了校准Heton参数,我正在尝试使用差分演化来优化成本函数。
def de(self):
bounds = [(0,1),(0.01,15), (0.01,1.), (-1,1), (0,1.0) ]
differential_evolution(self.f_cost, bounds, args=(True,), maxiter=100)
每次我运行上面的代码时,它会为我提供五个参数的nan值,但是如果我删除了
args=(True,)
它为我提供了真实的价值,但是我遇到了错误
686 if np.all(np.isinf(self.population_energies)):
687 self.population_energies[:] = self._calculate_population_energies(
--> 688 self.population)
689 self._promote_lowest_energy()
690
~\Anaconda3\lib\site-packages\scipy\optimize\_differentialevolution.py in _calculate_population_energies(self, population)
792 # wrong number of arguments for _mapwrapper
793 # or wrong length returned from the mapper
--> 794 raise RuntimeError("The map-like callable must be of the"
795 " form f(func, iterable), returning a sequence"
796 " of numbers the same length as 'iterable'")
RuntimeError: The map-like callable must be of the form f(func, iterable), returning a sequence of numbers the same length as 'iterable'
有人可以向我解释为什么会这样吗?