Linear Exponential Combination Fit
|
12-03-2020, 01:39 AM
(This post was last modified: 08-21-2023 03:42 PM by Albert Chan.)
Post: #2
|
|||
|
|||
RE: Linear Exponential Combination Fit
Hi, Eddie
Thanks for the post. I did not know HP Prime had LSQ function. It might be simpler not to create a flatten list (with CONCAT), then reconstruct the matrix. We could build the matrix, functional style: CAS> lx := range(6) CAS> ly := [2, 7, 13, 18, 26, 34] CAS> fit := LSQ(transpose([0*lx .+ 1., lx, e^lx]), ly) [[1.74935499144],[5.39455446221],[3.66584105036e−2]] CAS> [[1,x,e^x]] * fit [[ 3.66584105036E−2*e^x + 5.39455446221*x + 1.74935499144 ]] Comment: Aug 21, 2023 ".+" is supposed to apply sum element-by-element. However, XCas (lx-lx) .+ 1. does not populate matrix with all one's, (0*lx .+ 1.) does. To bypass the bug, above is adjusted so that both CAS, XCAS produce same results. Also, if we only need polynomial regression, there is a shortcut polynomial_regression(lx, ly, degree_needed) |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Linear Exponential Combination Fit - Eddie W. Shore - 11-30-2020, 03:45 PM
RE: Linear Exponential Combination Fit - Albert Chan - 12-03-2020 01:39 AM
|
User(s) browsing this thread: 1 Guest(s)