python - class method as a model function for scipy.optimize.curve_fit -


there statement in manual of curve_fit

the model function, f(x, ...). must take independent variable first argument , parameters fit separate remaining arguments.

however, use model function method of class defined as:

def model_fun(self,x,par): 

so, first argument not independent variable, can see. there way how can use method of class model function curve_fit

sure, create instance , pass bound method:

class myclass(object):    ...    def model_fun(self,x,par): ...  obj = myclass(...) curve_fit(obj.model_fun, ...) 

you can find explanation bound/unbound/etc. in this question.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -