使用iminuit指定(多)参数限制

2024-06-03 07:03:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我已尝试使用iminuit对参数设置限制,示例代码如下:

import iminuit

def func(x,y):
  fun = 2*x**2 + 3*y + 5
  return fun

m = iminuit.Minuit(func, x=1, y=1, limit_x=(0,100), limit_y=(0,50))

我得到的是错误消息

/usr/local/lib/python3.6/dist-packages/iminuit/minuit.py in _make_init_state(pos2var, args, kwds)
   1537             if kw not in pos2var:
   1538                 raise RuntimeError(
-> 1539                     f"{kw} is not one of the parameters [{' '.join(pos2var)}]"
   1540                 )
   1541         nargs = len(kwds)

RuntimeError: limit_x is not one of the parameters [x y]

这很奇怪,因为documentation以这种方式显示了限制的包含

我特别感兴趣的是一个更复杂的函数的最小化,有6个或更多的参数,指定其中2个的参数空间是很重要的


Tags: oftheinisnotoneiminuitparameters