LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Levenberg-Marquardt - termination?

 

  • Feed the current tick could via the data variant input when you call the nonlinear fit.
  • Inside the model function, take a tick count and subtract the tick count from the data variant.

 

 

If the difference is > 5000, generate an error inside the model and the fitting procedure will stop. 

 

Let me know if you need help with all that. 😉 

Message 11 of 26
(1,763 Views)

Hi altenbach,

 

Thanks very much.

 

I am unclear about the logic of your suggestion.  Isn't my model function called once for every iteration of the L-M algorithm?

 

Will this work?

 

 L-M halt execution.png

 

How do I generate an error inside the model function?  It has no error clusters.

 

Thanks again.

 

 

 

 

 

0 Kudos
Message 12 of 26
(1,754 Views)

Actually the L-M VI has an error out cluster.

 

Still unsure about the logic of your suggestion.  Please explain.

0 Kudos
Message 13 of 26
(1,751 Views)

This arrangement terminates too early.  The two tick values are almost identical but when I subtract them I get a huge number which is obviously much greater than 5000.  Please have a look and let me know what I'm doing wrong.

 

Notice my model function contains an infinite sum (while loop).

 

model function.png

0 Kudos
Message 14 of 26
(1,747 Views)

Switch the inputs of the subtract function. 🙂

 

(You need to subtract the "new tick count" from the "start tick count", and not vice versa.)

Message 15 of 26
(1,745 Views)

altenbach wrote: 

(You need to subtract the "new tick count" from the "start tick count", and not vice versa.)


 

 
Sorry, said it wrong: You need to subtract the "start tick count" from the "new tick count", and not vice versa. 
Message 16 of 26
(1,741 Views)

battler. wrote:

Notice my model function contains an infinite sum (while loop).


 

OK, this is probably a problem. Since you are terminating the inner loop based on a tolerance, the partial derivatives calculation will probably be suspect.

 

The model calculation as a function of parameter value is not a smooth function but will look more like a stair steps. You should probably calculate your own partial derivatives inside the model function to deal with this.

0 Kudos
Message 17 of 26
(1,738 Views)

How to calculate/implement the partial derivatives?

 

Do I have to do it analytically?  That could be a problem 😉  Can I do it numerically?  If so, how??

 

The function appears to return a correct fit of the parameters although there are numerous occasions when it can't solve and/or returns huge parameter values.

 

Thanks for your assistance.

0 Kudos
Message 18 of 26
(1,717 Views)
Isn't this the same function you asked about earlier?  If so I tested it out with this fit function VI.  I think you get something like 7 times more function calls when you use finite differences.
Message 19 of 26
(1,713 Views)

Thanks Darin, I appreciate that.

 

Can you please explain in more simple terms what you've done?

 

It looks like you may have implemented the partial derivatives (numerically?).  Did you work them out analytically?

 

I need to verify what you've done.

0 Kudos
Message 20 of 26
(1,708 Views)