本文整理汇总了Python中lmfit.Minimizer.fmin方法的典型用法代码示例。如果您正苦于以下问题:Python Minimizer.fmin方法的具体用法?Python Minimizer.fmin怎么用?Python Minimizer.fmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lmfit.Minimizer
的用法示例。
在下文中一共展示了Minimizer.fmin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_reactive_model
# 需要导入模块: from lmfit import Minimizer [as 别名]
# 或者: from lmfit.Minimizer import fmin [as 别名]
def run_reactive_model(y, inits, mu,std, ntrials=5000, maxfun=5000, ftol=1.e-3, xtol=1.e-3, all_params=1, ssdlist=[200,250,300,350,400,'rt'], learn=False, acc_vector=None, **kwargs):
#########################################################
# FITTING LEARN FX #
#########################################################
p=Parameters()
if all_params: vary=1
else: vary=0
#use this when fitting across all parameters.
for key, val in inits.items():
p.add(key, value=val, vary=vary)
#to fit only the learning terms, those should be the only terms added to the params dictionary.
#p.add('cor_lr', value= inits['cor_lr'], vary=vary)
#p.add('err_lr', value= inits['err_lr'], vary=vary)
popt = Minimizer(ssre_minfunc, p, fcn_args=(y, ntrials, mu, std),
fcn_kws={'learn':learn, 'acc': acc_vector}, method='Nelder-Mead')
popt.fmin(maxfun=maxfun, ftol=ftol, xtol=xtol, full_output=True, disp=False)
params=pd.Series({k:p[k].value for k in p.keys()})
res=popt.residual
res[-1]=res[-1]/10; y[-1]=y[-1]/10; yhat=y+res
pred=pd.DataFrame.from_dict({'ssdlist':ssdlist, 'ydata':y, 'residuals':res,
'yhat':yhat, 'chi':popt.chisqr}, orient='columns')
return pred, params