Python Forum

Full Version: using two arrays to fit a third one - find coefficients
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

I am new to python and coding so I am asking for your help.

Let's say I have two arrays (x1 = 0... 100, y1 = 0.1.... 0.2 and same for x2 and y2 ), these are spectra I measured.

I measured a third spectra (x3, y3, same dimensions as x1 and x2). I would like to know how

y3 = a*y1 + b*y2

what are the coefficients a and b that best fit spectra y3. This would need to be done with a least squares fit model. Can anyone help me model something like this?

Thank you very much.
are you familiar with numpy?

Least squares fit: https://docs.scipy.org/doc/numpy-1.14.0/...lstsq.html
or if polynomial needed: https://docs.scipy.org/doc/numpy/referen...lyfit.html