Program for Linear and Polynomial Fit

Program for Linear and Polynomial Fit - Messaggi

#1 Pubblicato: 08/12/2019 07:12:39
NDTM Amarasekera

NDTM Amarasekera

130 apprezzamenti in 352 post.

Gruppo: User

Simple examples on Linear and Polynomial fittings included as follows. This may be useful for beginners.
Examples 1 to 3 are for comparison only. Plot of given data is necessary to guess the distribution.

1. Ex. 1: Quadratic, posted by Martin
2. Ex.2: Ex.1 using SMath
3. Ex.3. Linear
4. Ex.4: A simple program to determine a suitable Linear / Polynomial fit to such data.

1.0 Linear & Poly Fits.sm (738,92 KiB) scaricato 1396 volta(e).

Linear_Poly Fits.png
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
1 utenti hanno apprezzato questo post
Alvaro 09/12/2019 03:41:00
#2 Pubblicato: 08/12/2019 12:12:47
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

Simple examples on Linear and Polynomial fittings included as follows.


SS 6179 does not open at all and may have crashed my session.
If SS 7251 syntax is not compatible, it just turns red.
As it looks, incompatible syntax in program is dead like a stone.
Voltaire declared [not exactly] ...
When a stone is dead, she is dead for a long time !

Why not simply open the red syntax program ?
The black regions SS 7251 have been reported many times,
still pending Doctors to come back from fishing.
Thanks Collab NDTMA

#3 Pubblicato: 08/12/2019 12:50:12
NDTM Amarasekera

NDTM Amarasekera

130 apprezzamenti in 352 post.

Gruppo: User

Wrote

SS 6179 does not open at all and may have crashed my session.


Sorry Jean. Forgot to attach the PDF. Thanks for your observations.

1.0 Linear & Poly Fits.pdf (683,54 KiB) scaricato 1019 volta(e).
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
1 utenti hanno apprezzato questo post
Alvaro 09/12/2019 03:41:00
#4 Pubblicato: 08/12/2019 16:49:45
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

Sorry Jean. Forgot to attach the PDF. Thanks for your observations.


Thanks for the *.PDF
Reconstructed c/w a lot more elegant export
Jean.

Polyfit Otherwise.sm (15,6 KiB) scaricato 1326 volta(e).
#5 Pubblicato: 08/12/2019 17:58:03
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

Reconstructed c/w a lot more elegant export
J


... a bit more/different but encountered "puzzling or bug".
Doctored but mystic.

Polyfit Otherwise.sm (22,44 KiB) scaricato 1263 volta(e).
#6 Pubblicato: 08/12/2019 23:21:29
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

... a bit more/different but encountered "puzzling or bug".
Doctored but mystic.


... suite/reconciliation from SS 5346 [works SS 6179]
Elegant and profitable, no bug/puzzling. Export polyfit.

Polynomial fit Methods [Regress Quick].sm (17,83 KiB) scaricato 1172 volta(e).
2 utenti hanno apprezzato questo post
frapuano 09/12/2019 14:41:00, NDTM Amarasekera 09/12/2019 13:31:00
#7 Pubblicato: 09/12/2019 10:32:33
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: User

Hi. This is another approach.

PolyFit.sm (18,44 KiB) scaricato 1337 volta(e).
PolyFit.pdf (162,98 KiB) scaricato 894 volta(e).

Best regards.
Alvaro

3 utenti hanno apprezzato questo post
NDTM Amarasekera 09/12/2019 13:31:00, frapuano 09/12/2019 14:41:00, sergio 09/12/2019 11:46:00
#8 Pubblicato: 09/12/2019 21:11:33
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

This is another approach.


Thanks Alvaro ... superb ! Jean.
That black regions is really a pen in the ass.

PolyFit [Alvaro Balistic].sm (22,1 KiB) scaricato 1187 volta(e).

#9 Pubblicato: 09/12/2019 23:18:06
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

... added HadCRU [Hadley Climate Research Unit]
Global warming 1950 ... 2019 °C deviation wrt period 1950/1960
Fit on ChebyShev ± 1 and recovered on separate document.

PolyFit [Alvaro Balistic].sm (133,63 KiB) scaricato 1087 volta(e).

#10 Pubblicato: 10/12/2019 02:15:11
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

Fit on ChebyShev ± 1 and recovered on separate document.


... here is HadCRU fitted in the ChebyShev ± 1
then recovered in the original 1950 ... 2019 range.
It has nothing to do with the PolyFit(X,Y,n)
simply that high order polynomials are numerically
unstable at high range of the variate 'x'.
It has nothing to do with the CAS or floating arithmetic,
simply an Edu mathematical fact.

PolyFit [Alvaro Balistic].sm (310,61 KiB) scaricato 1097 volta(e).
#11 Pubblicato: 10/12/2019 12:36:43
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

... here is HadCRU fitted in the ChebyShev ± 1


... the clean/refreshed Edu version.

PolyFit [Alvaro Balistic].sm (230,72 KiB) scaricato 1138 volta(e).
#12 Pubblicato: 10/12/2019 13:17:44
NDTM Amarasekera

NDTM Amarasekera

130 apprezzamenti in 352 post.

Gruppo: User

Wrote

Simple examples on Linear and Polynomial fittings included as follows.


Another method
PolyCoef.png
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
#13 Pubblicato: 10/12/2019 18:14:55
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

Simple examples on Linear and Polynomial fittings included as follows.


... tested/fails [Uncertainty]

Poly 00 NDTMA.sm (112,87 KiB) scaricato 1346 volta(e).
1 utenti hanno apprezzato questo post
NDTM Amarasekera 10/12/2019 23:30:00
#14 Pubblicato: 10/12/2019 19:00:23
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: User

Wrote

Wrote

Simple examples on Linear and Polynomial fittings included as follows.


... tested/fails [Uncertainty]

Poly 00 NDTMA.sm (112,87 KiB) scaricato 1346 volta(e).



Hi. Here

Clipboard01.gif

the code (el(x,r)≡0)&(c≡1) for construct the Vandermonde matrix is for avoid 0^0, which returns the error.

Also, I avoid augment in the recursive loops because it's frustratingly slow.

Finlay, the code for PolyVal it's very inefficient, it's only for pedagogical purposes. Horner must be implemented for some other application. Notice that both are matlab/octave/scilab routines too.

In my opinion, the intention of Nugegodage to replicate ms excel results in SMath is very important, to promote SMaths as better alternative to excel doing math.

Best regards.

Alvaro.
1 utenti hanno apprezzato questo post
NDTM Amarasekera 10/12/2019 23:30:00
#15 Pubblicato: 10/12/2019 19:40:48
CBG

CBG

78 apprezzamenti in 312 post.

Gruppo: User

Same exercises by Cholesky's method.

Cholesky_Function.png

Cholesky_Function_CBG_Jean_SS7251.sm (168,3 KiB) scaricato 1369 volta(e).

Cholesky_Function_CBG_Jean_SS6179.sm (166,42 KiB) scaricato 1336 volta(e).


Best Regards

Carlos
1 utenti hanno apprezzato questo post
NDTM Amarasekera 10/12/2019 23:30:00
#16 Pubblicato: 10/12/2019 23:21:00
NDTM Amarasekera

NDTM Amarasekera

130 apprezzamenti in 352 post.

Gruppo: User

Thank you Jean, Alvaro and Carlos for your valuable responses.
BTW, I too get "uncertainty" error in Jean's example. Hope these issues will be resolved soon.
Once again Thank You all.
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
#17 Pubblicato: 10/12/2019 23:58:52
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: User

Hi. R2 like ms excel added. And tome other alternatives for solve the matrix.

PolyFit.sm (152,04 KiB) scaricato 1324 volta(e).
PolyFit.pdf (693,6 KiB) scaricato 868 volta(e).

Best regards.
Alvaro.
#18 Pubblicato: 11/12/2019 01:42:29
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

Thank you Jean, Alvaro and Carlos for your valuable responses.
BTW, I too get "uncertainty" error in Jean's example. Hope these issues will be resolved soon.


Resolved in the attached from coding Cholesky the right way.
Alvaro code was OK too.
All in all, purely polynomials have so few applications
that they don't worth more than a short Classroom introduction.
On the other hand, the vector of functions is lot more productive.
And BTW, it is the form for the Conjugate Gradient model fitting.
Jean.

Poly 000 jmG Conjugate Gradient.sm (49,54 KiB) scaricato 1302 volta(e).
Poly 000 jmG.sm (146,39 KiB) scaricato 1309 volta(e).



#19 Pubblicato: 11/12/2019 05:33:00
Martin_B

Martin_B

22 apprezzamenti in 84 post.

Gruppo: User

That's my solution
- to separate the functions from matrix building,
- to use vectorize for speed

polyfit.png
#20 Pubblicato: 11/12/2019 11:44:36
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

That's my solution
- to separate the functions from matrix building,
- to use vectorize for speed


Thanks for your effort/contribution.
Sorry, but too much of a monkey business.
Here are the two elegant Cholesky linear solver:
1. The modular local utility [Mathcad linfit style]
2. The general algo style as an Smath native.
Works same SS 6179 from original created SS 5346.
Hope this document will tranquilize visitors/users !

Jean.

Poly 000 jmG linfit MCD.sm (34,52 KiB) scaricato 1344 volta(e).
  • Nuovi post
  • Nessun nuovo post