I am trying to do a regression of a nonlinear system with a set of data.
import numpy as np
xdata = np.array([3, 6, 9, 12, 24]) #ydata1 and ydata2 use the same xdata
ydata1 = np.array([5e-4, 5.03e-4, 4.56e-4, 4,89e-4, 4.85e-4])
ydata2 = np.array([1.7e-3, 1.74e-3, 1.64e-3, 1.74e-3, 1.69e-3])
xdata3 = np.array([3, 6, 9, 18])
ydata3 = np.array([2.74e-3, 2.68e-3, 2.62e-3, 2.92e-3])
These three lines use the same function except one parameter p1, would I know whether there is a simple example to illustrate how to use curve_fit to solve this system simultaneously(globally). Thank you so much!
def func(a, b, x):
return a * b * p1 * x / ((1 + np.sqrt(b * x)) ** 2)
### p1 is 6, 18, 30 for ydata1, ydata2, ydata3