Python Forum
using two arrays to fit a third one - find coefficients
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using two arrays to fit a third one - find coefficients
#1
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.
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  AR roots for VAR coefficients Scott 2 1,020 Nov-30-2022, 09:23 PM
Last Post: Scott
  comparing floating point arrays to arrays of integers in Numpy amjass12 0 1,613 Jul-26-2021, 11:58 AM
Last Post: amjass12
  Neural Network importance weights / coefficients jkaustin 1 2,027 Nov-10-2020, 07:44 PM
Last Post: jefsummers
  Outputing LogisticRegression Coefficients (sklearn) RawlinsCross 6 4,656 Feb-27-2020, 02:47 PM
Last Post: RawlinsCross
  Numpy arrays and compatability with Fortran arrays merrittr 0 1,849 Sep-03-2019, 03:54 AM
Last Post: merrittr
  fit each group and extract coefficients Progressive 1 2,882 Jul-20-2019, 08:20 AM
Last Post: scidam
  Printing coefficients Scott 1 5,703 Jun-30-2018, 12:14 PM
Last Post: gontajones

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020