Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


2 Pages12>
Options
Go to last post Go to first unread
Offline ndtma  
#1 Posted : 08 December 2019 13:12:39(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 125 time(s) in 82 post(s)
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 (739kb) downloaded 68 time(s).

Linear_Poly Fits.png

Edited by user 08 December 2019 13:18:33(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
thanks 1 user thanked ndtma for this useful post.
on 09/12/2019(UTC)

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Jean Giraud  
#2 Posted : 08 December 2019 18:12:47(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: ndtma Go to Quoted Post
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

Offline ndtma  
#3 Posted : 08 December 2019 18:50:12(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 125 time(s) in 82 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
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 (684kb) downloaded 60 time(s).

Edited by user 08 December 2019 18:52:18(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
thanks 1 user thanked ndtma for this useful post.
on 09/12/2019(UTC)
Offline Jean Giraud  
#4 Posted : 08 December 2019 22:49:45(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: ndtma Go to Quoted Post
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 (16kb) downloaded 39 time(s).
Offline Jean Giraud  
#5 Posted : 08 December 2019 23:58:03(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Reconstructed c/w a lot more elegant export
J

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

Polyfit Otherwise.sm (23kb) downloaded 26 time(s).
Offline Jean Giraud  
#6 Posted : 09 December 2019 05:21:29(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
... 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 (18kb) downloaded 43 time(s).
thanks 2 users thanked Jean Giraud for this useful post.
on 09/12/2019(UTC),  on 09/12/2019(UTC)
Offline Razonar  
#7 Posted : 09 December 2019 16:32:33(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi. This is another approach.

PolyFit.sm (19kb) downloaded 45 time(s).
PolyFit.pdf (163kb) downloaded 49 time(s).

Best regards.
Alvaro

thanks 3 users thanked Razonar for this useful post.
on 09/12/2019(UTC),  on 09/12/2019(UTC),  on 09/12/2019(UTC)
Offline Jean Giraud  
#8 Posted : 10 December 2019 03:11:33(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Razonar Go to Quoted Post
This is another approach.

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

PolyFit [Alvaro Balistic].sm (23kb) downloaded 27 time(s).

Offline Jean Giraud  
#9 Posted : 10 December 2019 05:18:06(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
... 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 (134kb) downloaded 18 time(s).

Offline Jean Giraud  
#10 Posted : 10 December 2019 08:15:11(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
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 (311kb) downloaded 22 time(s).
Offline Jean Giraud  
#11 Posted : 10 December 2019 18:36:43(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
... here is HadCRU fitted in the ChebyShev ± 1

... the clean/refreshed Edu version.

PolyFit [Alvaro Balistic].sm (231kb) downloaded 26 time(s).
Offline ndtma  
#12 Posted : 10 December 2019 19:17:44(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 125 time(s) in 82 post(s)
Originally Posted by: ndtma Go to Quoted Post
Simple examples on Linear and Polynomial fittings included as follows.

Another method
PolyCoef.png

Edited by user 10 December 2019 19:19:47(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
Offline Jean Giraud  
#13 Posted : 11 December 2019 00:14:55(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: ndtma Go to Quoted Post
Simple examples on Linear and Polynomial fittings included as follows.

... tested/fails [Uncertainty]

Poly 00 NDTMA.sm (113kb) downloaded 27 time(s).
thanks 1 user thanked Jean Giraud for this useful post.
on 11/12/2019(UTC)
Offline Razonar  
#14 Posted : 11 December 2019 01:00:23(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Originally Posted by: ndtma Go to Quoted Post
Simple examples on Linear and Polynomial fittings included as follows.

... tested/fails [Uncertainty]

Poly 00 NDTMA.sm (113kb) downloaded 27 time(s).


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.
thanks 1 user thanked Razonar for this useful post.
on 11/12/2019(UTC)
Offline CBG  
#15 Posted : 11 December 2019 01:40:48(UTC)
CBG


Rank: Advanced Member

Groups: Registered
Joined: 14/10/2015(UTC)
Posts: 308

Was thanked: 77 time(s) in 58 post(s)
Same exercises by Cholesky's method.

Cholesky_Function.png

Cholesky_Function_CBG_Jean_SS7251.sm (169kb) downloaded 26 time(s).

Cholesky_Function_CBG_Jean_SS6179.sm (167kb) downloaded 24 time(s).


Best Regards

Carlos
thanks 1 user thanked CBG for this useful post.
on 11/12/2019(UTC)
Offline ndtma  
#16 Posted : 11 December 2019 05:21:00(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 125 time(s) in 82 post(s)
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
Offline Razonar  
#17 Posted : 11 December 2019 05:58:52(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi. R2 like ms excel added. And tome other alternatives for solve the matrix.

PolyFit.sm (153kb) downloaded 31 time(s).
PolyFit.pdf (694kb) downloaded 28 time(s).

Best regards.
Alvaro.
Offline Jean Giraud  
#18 Posted : 11 December 2019 07:42:29(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: ndtma Go to Quoted Post
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 (50kb) downloaded 22 time(s).
Poly 000 jmG.sm (147kb) downloaded 23 time(s).



Offline MarB  
#19 Posted : 11 December 2019 11:33:00(UTC)
MarB


Rank: Advanced Member

Groups: Registered
Joined: 21/10/2016(UTC)
Posts: 84

Was thanked: 21 time(s) in 17 post(s)
That's my solution
- to separate the functions from matrix building,
- to use vectorize for speed

polyfit.png
Offline Jean Giraud  
#20 Posted : 11 December 2019 17:44:36(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: MarB Go to Quoted Post
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 (35kb) downloaded 42 time(s).
Users browsing this topic
Guest
2 Pages12>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.