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 CBG  
#1 Posted : 21 December 2019 06:50:23(UTC)
CBG


Rank: Advanced Member

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

Was thanked: 77 time(s) in 58 post(s)
Reviewing the Levenberg Marquardt Method with a Jacobian matrix for finite differences,
solving an example taken from the website:
http://support.ptc.com/h...east_squares_fitting.htm .

LMM revisits.png

Algorithm_Levenberg_M_with_DF_SS7251.sm (211kb) downloaded 42 time(s).

Algorithm_Levenberg_M_with_DF_SS7251.pdf (570kb) downloaded 41 time(s).


Best Regards

Carlos

Edited by user 21 December 2019 07:47:33(UTC)  | Reason: Not specified

thanks 2 users thanked CBG for this useful post.
on 21/12/2019(UTC),  on 27/12/2019(UTC)

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

Offline mkraska  
#2 Posted : 21 December 2019 14:34:27(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,980
Germany

Was thanked: 1120 time(s) in 718 post(s)
Solution using the Maxima package lsquares via the interface functions of the Maxima plugin

fit1.png
fit1.sm (30kb) downloaded 42 time(s).
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 2 users thanked mkraska for this useful post.
on 21/12/2019(UTC),  on 21/12/2019(UTC)
Offline Jean Giraud  
#3 Posted : 21 December 2019 19:27:24(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Thanks: Carlos, Martin.
SS 6179 does not complain but still pedaling in 10 min ???

1. in Mathcad [8 Pro ... 11] type ERR= after Minerr
ERR is undocumented = SSD [discovered by Paul W.]
2. alternate to corr, SSD sometimes meaningless [Viod ratio, Verhulst].
3. Often, the best fit is Conjugate Gradient.

Jean

Genfit VoidRatio.sm (66kb) downloaded 27 time(s).
Genfit Verhulst.sm (57kb) downloaded 23 time(s).
Genfit Weibull.sm (55kb) downloaded 26 time(s).
Offline CBG  
#4 Posted : 24 December 2019 09:13:34(UTC)
CBG


Rank: Advanced Member

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

Was thanked: 77 time(s) in 58 post(s)
Thanks, Martin

Hello Jean:

I tried to run the algorithm of Levenberg Marquardt, in the version of SS6179,
but it inevitably fails, giving an incorrect solution.

It seems that the error could be in some operation where a single value vector
is produced. Could you take a look to see if you can doctorate ?.

I post again the version of the algorithm in SS7251 with some minor changes.

LMM revisits_R1.png

Algorithm_Levenberg_M_with_DF_SS6179.sm (514kb) downloaded 25 time(s).

Algorithm_Levenberg_M_with_DF_SS7251_R1.sm (210kb) downloaded 21 time(s).


Best Regards

Carlos
Offline Jean Giraud  
#5 Posted : 26 December 2019 18:11:47(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: CBG Go to Quoted Post
It seems that the error could be in some operation where a single value vector
is produced. Could you take a look to see if you can doctorate ?.

Helo Carlos,
I deleted all previous postings of no more interest.
I found no way to iterate LM ? Otherwise, easy to initialize
from the al_nleqsolve as suggested in the last part of the attached.
In Mathcad, LM was found hyper robust to initialize,
but most of the times, better fit are concluded from CG.

The Weibull example is one of the easiest to fit.
Very many aren't so easy to fit from model(s), more reflexive.
Some model functions can't be fitted at all, unless from trial/error.
A great piece of work, to get familiarized in fitting session.
Thanks Carlos ... Jean

Genfit Weibull [LM_Iteretive CG] Copy.sm (437kb) downloaded 20 time(s).
Offline Jean Giraud  
#6 Posted : 26 December 2019 18:46:45(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
I found no way to iterate LM ? Otherwise, easy to initialize
from the al_nleqsolve as suggested in the last part of the attached.

... then like this:
refit from observing the bar deviation.

Genfit Weibull [LM,al_nleqsolve Companion].sm (103kb) downloaded 16 time(s).
Offline Jean Giraud  
#7 Posted : 26 December 2019 20:24:39(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
... then like this:
refit from observing the bar deviation.

... the fully tutored version.

Genfit Weibull [LM,al_nleqsolve Companion] Copy.sm (105kb) downloaded 28 time(s).
Offline CBG  
#8 Posted : 27 December 2019 05:29:57(UTC)
CBG


Rank: Advanced Member

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

Was thanked: 77 time(s) in 58 post(s)
Hello Jean

Thank you very much.

The question is: Why does the SS7251 version directly obtain the solution,
changing the values correctly of the β variable, while the SS6179 version does not,
and they have to be manually entered as new values of the vector of the assumed initial solution. ?

The algorithm is the same for the 2 versions of SmathStudio, so what is the difference if the
programming and decision definitions are supposed to work the same?

Best Regards

Carlos
Offline Jean Giraud  
#9 Posted : 27 December 2019 06:35:45(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: CBG Go to Quoted Post
Thank you very much.

The question is: Why does the SS7251 version directly obtain the solution,
changing the values correctly of the β variable, while the SS6179 version does not,
and they have to be manually entered as new values of the vector of the assumed initial solution. ?

The algorithm is the same for the 2 versions of SmathStudio, so what is the difference if the
programming and decision definitions are supposed to work the same?

A most interesting observation !
SS 6179 may have to do with the conditional statement.
SS 6179 is "zero" tolerance. So, it may just navigate then end.
It could be SS 7251 conditional is coded more tolerant
Mathcad style and reaches convergence ? Watson, are you there ?
Cheers Carlos ... later on.
Offline Razonar  
#10 Posted : 27 December 2019 09:09:57(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: CBG Go to Quoted Post
Hello Jean

Thank you very much.

The question is: Why does the SS7251 version directly obtain the solution,
changing the values correctly of the β variable, while the SS6179 version does not,
and they have to be manually entered as new values of the vector of the assumed initial solution. ?

The algorithm is the same for the 2 versions of SmathStudio, so what is the difference if the
programming and decision definitions are supposed to work the same?

Best Regards

Carlos


Hola Carlos. Just check the code from the SS6179 version, in the while not(stop) loop, the line with A:=J^T*f is wrong, it must to be A:=J^T*J.

Best regards.
Alvaro.
thanks 1 user thanked Razonar for this useful post.
on 27/12/2019(UTC)
Offline Jean Giraud  
#11 Posted : 27 December 2019 21:47:32(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Razonar Go to Quoted Post
Hola Carlos. Just check the code from the SS6179 version, in the while not(stop) loop, the line with A:=J^T*f is wrong, it must to be A:=J^T*J.

Thanks Alvaro ... doctored !
Weibull LM [0.1,1] 1 min
Weibull CG [0.1,1] 2.3 sec ... ½ max residual deviation
Carlos, your very original LM [Pharmacokinetics] works faster.
an it be compacted algo style ... tried not to avail ?

Hola ! Avaro, Carlos ... Jean

Genfit Weibull [LM_Iteretive CG].sm (438kb) downloaded 21 time(s).
Genfit [Algo Minimize(L-M)].sm (117kb) downloaded 20 time(s).
Offline CBG  
#12 Posted : 28 December 2019 02:37:54(UTC)
CBG


Rank: Advanced Member

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

Was thanked: 77 time(s) in 58 post(s)
Originally Posted by: Razonar Go to Quoted Post


Hola Carlos. Just check the code from the SS6179 version, in the while not(stop) loop, the line with A:=J^T*f is wrong, it must to be A:=J^T*J.

Best regards.
Alvaro.


Hola Alvaro.

Muchas gracias por tu corrección.

Cuando copie y pegue directamente el codigo de SS7251 a SS6179 daba el error de
"Ecuacion demasiado larga para visualizarla" con un tiempo de ejecusion de mas de 7 minutos,
por lo que opté por copiar manualmente el codigo, pensando que las declaraciones eran interpretados erroneamente, y
fue cuando copie mal la formula.


Hello Alvaro.

Thank you very much for your correction.

When copying and pasting directly the code from SS7251 to SS6179 it gave the error of
"Equation too long to display" with an execution time of more than 7 minutes,
So I chose to manually copy the code, thinking that the statements were misinterpreted, and
It was when I copied the formula badly.

Muchas gracias tambien a Jean por su apoyo y sus comentarios tan acertados.


Best Regards

Carlos
Offline Jean Giraud  
#13 Posted : 28 December 2019 04:14:29(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: CBG Go to Quoted Post
Muchas gracias tambien a Jean por su apoyo y sus comentarios tan acertados.

I Understand Carlos ...
Now, for your bed time reading, these two fits level Mathcad GenfitMatrix.
By far, they beat former NBS-125.
Rational fractions have exceptional fitting/interpolation virtues.
Thanks and credit to Jeff who helped me so much ...
About same timing as MCD 11

Jean ... enjoy.

Genfit 0000000 Rational Auto-init ITER Copy.sm (150kb) downloaded 19 time(s).

Offline John Suh  
#14 Posted : 09 January 2020 04:47:05(UTC)
John Suh

Rank: Newbie

Groups: Registered
Joined: 09/01/2020(UTC)
Posts: 1
Location: Chicago

Originally Posted by: mkraska Go to Quoted Post
Solution using the Maxima package lsquares via the interface functions of the Maxima plugin

fit1.png
fit1.sm (30kb) downloaded 42 time(s).my god.. i didn't know this was a thing! i'm really glad a friend led me to this forum. hey can you check out this website? solidpapers.com was where I had one of my geometry homework done and I got a passing grade! can you see if it also works for you? i'm planning to order another paper from them again. tell me what you think!!!


Offline Jean Giraud  
#15 Posted : 09 January 2020 14:29:55(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Fitting data set is a long discours, much longer in techniques/methods.
The Mathcad/Mathsoft LM is the quick/robust ... bingo/done.
Not the best in very many instances.
Attach your data set in this Forum.
Make sure they are raw data from collection, i.e: not freaked by unknown.
Cheers ... are we going to see you again ?
Offline Jean Giraud  
#16 Posted : 10 January 2020 05:14:39(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: John Suh Go to Quoted Post
my god.. i didn't know this was a thing!

1. al_nleqsolve fits the model through selected equalities.
The data set may be moderately noisy.
2. GenfiMinimize is essentially the Cholesky LS solver.
My collection is not lean [177 documents ...some duplicates].

Genfit linfit HyperRobust [Ge Crystal].sm (82kb) downloaded 19 time(s).
Genfit [Algo Minimize(al_nleqsolve Alco, Thurber)].sm (86kb) downloaded 21 time(s).
Offline CBG  
#17 Posted : 14 January 2020 23:42:56(UTC)
CBG


Rank: Advanced Member

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

Was thanked: 77 time(s) in 58 post(s)

I Understand Carlos ...




Hello Jean
I know you understand perfectly, and that has been the intention.

The second Levenberg Marquardt algorithm has been passed as a function
in the versions of SS7251 and SS6179, the examples published by Jean in
"Genfit linfit HyperRobust [Ge Crystal] .sm"
and 2 other previous examples have also been solved.

Unfortunately, version SS6179, for unknown reasons
does not solve the first example, and results in the
same starting solution vector, the other examples are solved without problem.

LM2A_as_a_Function_SS7251.sm (151kb) downloaded 17 time(s).

LM2A_as_a_Function_SS6179.sm (145kb) downloaded 18 time(s).


Best Regards

Carlos
thanks 1 user thanked CBG for this useful post.
on 15/01/2020(UTC)
Offline Jean Giraud  
#18 Posted : 15 January 2020 21:39:52(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Unfortunately, version SS6179, for unknown reasons
does not solve the first example, and results in the
same starting solution vector, the other examples are
solved without problem.


Hola ! Carlos.
You don't specify if the SS 7251 solves that example.
Please, don't drop dead at reading.
This example attached, Mathcad [L-M, CG, QN] does not even
return the exact coefficients. I tortured myself on that.
On the other hand as well, many model functions can't be
fitted from being too much reflexive within themselves.
For those non willing fit, al_nleqsolve will generally succeeds.
Mathcad failed as well the ITER Cadarache Cu resistivity.
Was done otherwise via sub methods. At least for ITER,
Mathcad returned: "Too complicated to solve"
u:=(0≤x)*(x≤10) useful constrain the Quick plot.
Thanks for your immense dedication.

Jean

Genfit [Algo Minimize(al_nleqsolve Pharmacokinetics) ... AUTOMATED] Copy.sm (105kb) downloaded 14 time(s).
Offline CBG  
#19 Posted : 16 January 2020 02:16:40(UTC)
CBG


Rank: Advanced Member

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

Was thanked: 77 time(s) in 58 post(s)
Hola Jean!

Levenberg Marquardt's second algorithm in SS7251 does solve the example. All data
with a tolerance of 10 ^ -16 can be used, or 4 selected data with a tolerance of
10 ^ -8 can be used, in both cases, the starting vector is [0.5 1 1 1].

LMSA.png

LM2A_as_a_Function_SS7251_R1.pdf (799kb) downloaded 17 time(s).

LM2A_as_a_Function_SS7251_R1.sm (206kb) downloaded 20 time(s).

The idea was to run the LM algorithm as a function for SS7251 and SS6179, for which
use your examples.

Jean, I tell you that I take the results you show in your exercises as the exact or correct ones

Thank you

Best Regards

Carlos
thanks 1 user thanked CBG for this useful post.
on 16/01/2020(UTC)
Offline Jean Giraud  
#20 Posted : 16 January 2020 21:35:31(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: CBG Go to Quoted Post
Jean, I tell you that I take the results you show in your exercises as the exact or correct ones

They are all correct, good fit from model.
There are many more techniques to best fit by region(s)
The last example SS 6179 spits the fit very fast vs other
solvable previous examples ... supports tol 0.00000001.
Comfort yourself: model fit needs no more than 6 decimals
or less ... from zillions done.
Thanks Carlos for your doctoring expertise.

Jean

Genfit 000000000000 L-M AUTOMATED Carlos 20200115 [Exampless].sm (212kb) downloaded 21 time(s).

Users browsing this topic
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.