Using Scipy curve_fit with variable number of parameters to optimize
问题 Assuming we have the below function to optimize for 4 parameters, we have to write the function as below, but if we want the same function with more number of parameters, we have to rewrite the function definition. def radius (z,a0,a1,k0,k1,): k = np.array([k0,k1,]) a = np.array([a0,a1,]) w = 1.0 phi = 0.0 rs = r0 + np.sum(a*np.sin(k*z +w*t +phi), axis=1) return rs The question is if this can be done easier in a more automatic way, and more intuitive than this question suggests. example would