1

I am trying to fit a function to a set of variables using the ODR function. The task at hand doesn’t seem to be that difficult, but the whole idea of an estimator really confuses me. I read the description of the function and all of its inputs, but I can’t quite understand the significance of the estimator. I wanted it to be calculated somehow, instead of just guessing it myself, but the functions I tried, linregress (can be used for linear function only), and curve_fit (also requires an estimator, but assumes the value as 1 if not provided) were of no help. What does the estimator mean? How do I find one? How do I get the ODR function to be as precise as possible? Where can I find such info? Thanks.

EDIT: here's a piece of the code

def fun(kier, arg):
    '''
    Function to fit
    :param kier: list of parameters
    :param arg: argument of the function fun
    :return y: value of function in x
    '''

    y =kier[0]*arg +1 #+kier[1]
    return y

dane = RealData(x=zx, y=zy, sx=dx, sy=dy)
model = Model(fun)
#kier,cross,none,none,none=linregress(zx_mean,zy_mean) #this is a method used to estimate the parameters, replaced by curve_fit.
popt, pcov = curve_fit(fun, zx, zy)
on = ODR(dane, model,beta0=[popt[0]])
output = on.run()
PKK
  • 31
  • 4
  • You should supply more information such as you code and what you have tried so far. – Green Apr 10 '20 at 13:33
  • Okay, I tried to learn how to obtain the estimator by reading the description of both of the functions and it’s variables on websites such as scipy.org, but it doesn’t say how to obtain it. I tried using linregress that doesn’t require an estimate, but it would only work for linear functions with unknown parameters, while the linear function I am fitting now has to cross the Y axis in a set point (egz. y=a*x+100), and I might need to fit a polynomial in the future. I am trying to get the resultant parameters to be as precise as possible. I’ll add a piece of the code to the original post. – PKK Apr 14 '20 at 11:42

0 Answers0