I have a situation where two or more nd arrays, with some coefficients, should add up (roughly) to a third array.
array1*c1 + array2*c2 ... = array3
I’m looking for the c1 and c2 that make the first two arrays best approximate array3. I’m sure some way of doing this exists in scipy, but I’m not sure where to start. Is there are specific module I should begin with?
numpy.linalg.lstsq solves this for you. Object-oriented wrappers for that function, as well as more advanced regression models, are available in both scikit-learn and StatsModels.
(Disclaimer: I’m a scikit-learn developer, so this is not the most unbiased advice ever.)