简体   繁体   English

在 SciPy LeastSq 中获取变量以使用它们

[英]Get Variables in SciPy LeastSq to use them

I need to get fitting result for each parameter created in each least_sq run.我需要为每个 minimum_sq 运行中创建的每个参数获取拟合结果。 Can anyone guide me on Parameter names inferred from the function arguments in the SciPy LeastSq??谁能指导我从 SciPy LeastSq 中的函数参数推断的参数名称?

** Good news! ** 好消息! using the lmfit such a wonderful package!**使用lmfit这么棒的包!**

from scipy.optimize import least_squares
from matplotlib.pylab import plt
import numpy as np
from numpy import exp, linspace, random
from lmfit import Model


def gaussian(x, amp, cen, wid):
    return amp * np.exp(-(x-cen)**2 / wid)


x = linspace(-10, 10, 101)
y = gaussian(x, 2.33, 0.21, 1.51) + random.normal(0, 0.2, len(x))

gmodel = Model(gaussian)
params = gmodel.make_params()
print('parameter names: {}'.format(gmodel.param_names))
print('independent variables: {}'.format(gmodel.independent_vars))
result = gmodel.fit(y, params, x=x, amp=5, cen=5, wid=1)
print(result.fit_report())
[n many cases we might want to extract parameters and standard error estimates programatically rather than by reading the fit report][1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在yii中声明全局变量并在控制器中使用它们 - declaring global variables in yii and use them in controller 类变量的问题,在功能块中使用它们 - Problem with class variables , to use them in if block in function 在另一个类中使用带有变量的函数或方法? C# - Use a function or method with variables in them in another class? C# 将变量传递到函数和通过USE导入变量之间有什么区别吗? - Is there any difference between passing variables into function and import them by USE? 在pyinstaller中添加2个数据文件,在脚本编写的函数中作为变量使用 - Add 2 data files in pyinstaller and use them as variables in the function written in the script 如何使用get()构造变量的复杂模型 - How to use get() to construct a complicated model of variables jQuery从类中获取参数并在函数中使用它们 - jQuery get parameters from class and use them on functions 我有一个带有许多变量的 function。 如何在另一个 function 中使用它们? - I have a function with many variables. How do I use them in another function? 如何将变量从一个 function 传递到另一个,并在 python 的条件语句中使用它们? - How do I pass variables from one function to another and use them in conditional statements in python? 函数和在其中定义变量的问题 - Trouble with functions and defining variables in them
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM