Fitting only one parameter of a function with many parameters in python

前端 未结 7 1771
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 07:55

In python I have a function which has many parameters. I want to fit this function to a data set, but using only one parameter, the rest of the parameters I want to supply o

相关标签:
7条回答
  • 2020-12-01 08:15

    I effectively use Anton Beloglazov's solution, though I like to avoid using lambda functions for readability so I do the following:

    def func(x,a,b):
       return a*x*x + b
    
    def helper(x,a):
       return func(x,a,b)
    
    for b in xrange(10):
       popt,pcov = curve_fit(helper, x1, x2)
    

    This ends up being reminiscent of Rick Berg's answer, but I like having one function dedicated to the "physics" of the problem and a helper function to get the code to work.

    0 讨论(0)
提交回复
热议问题