Using scipy curve_fit for a variable number of parameters
I have a fitting function which has the form: def fit_func(x_data, a, b, c, N) where a, b, c are lists of lenth N, every entry of which is a variable parameter to be optimized in scipy.optimize.curve_fit(), and N is a fixed number used for loop index control. Following this question I think I am able to fix N, but I currently am calling curve_fit as follows: params_0 = [a_init, b_init, c_init] popt, pcov = curve_fit(lambda x, a, b, c: fit_func(x, a, b, c, N), x_data, y_data, p0=params_0) I get an error: lambda() takes exactly Q arguments (P given) where Q and P vary depending on how I am