Fitting a vector function with curve_fit in Scipy
问题 I want to fit a function with vector output using Scipy's curve_fit (or something more appropriate if available). For example, consider the following function: import numpy as np def fmodel(x, a, b): return np.vstack([a*np.sin(b*x), a*x**2 - b*x, a*np.exp(b/x)]) Each component is a different function but they share the parameters I wish to fit. Ideally, I would do something like this: x = np.linspace(1, 20, 50) a = 0.1 b = 0.5 y = fmodel(x, a, b) y_noisy = y + 0.2 * np.random.normal(size=y