I'm using the built-in Levenberg-Marquardt algorithm to fit some data. It calls some function which needs to have the syntax foo(x,a1,a2,...,an), where an are parameters and the number of input arguments specifies the number of dimensions the L-M algorithm minimizes. Currently this foo function calls some other function I have defined as :
foo(x, a1, a2, ..., an):
ai = [a1,a2,...,an]
result = somefun(x,ai)
return result
Is there a way to use a compact syntax in this case? I would like to be able to define some parameter L = n
, which specifies the number of input arguments somewhere before the function definition.
Note: Please also read that using
foo(x,*ai)
, will generateValueError: Unable to determine number of fit parameters
before marking as duplicate.