I have a general class of non-linear problem where I have 2 or more vectors of y-data that are coupled in a dependent, but known, way to 2 or more vectors of x-data, and I want to find the parameters. I'm looking for a way to adapt the basic non-linear fit model in python to take both sets of data into account.
In a general case, I might have the pair:
[y1(x1, x2; A, B), y2(x1, x2; A, B)]
As a concrete example, I might have:
y1 = A sin(B x1) + e^(-A x1)
y2 = A x1^2 + B x2 + log[A x2]
(Assume these are not analytically solvable, or might present inefficiencies if solved). I know all the values y1, y2
and x1, x2
, and I want to find an estimate for A
and B
that takes into account the data from both ys
. I could just fit one or the other equation and get an estimate for A
and B
.
For example, imagine if y2
did not depend on B
(or did so very weakly). It still gives strong information about the value of A
that I want y1
to take into account.
As a secondary question, how would I use this method to put different weights on the two sets of the y-data?
Edit:
One potential approach I can think of would be to stack all the y-data into a single column, and then use the function to process the expected y1,y2
, and then end the function with something like return vstack((y1,y2))
so I could compare the two sets? Then I could just have a weighting function that matches the length of this joined function?