LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Poor Optomization with Constrained Non-linear Fit

I'm trying to build a fitting routine to fit my data to the function f(x) = A*exp[-(x/t)^b)]+c.  Since b must be less than or equal to 1 and greater than zero, I'm using a constrained non-linear fit.  Eventually this is going to be integrated into a larger program to do real time fitting as I collect my data, but for the moment I've added an array of old data that I've already fit elsewhere.  

 

My issue is that the parameters I'm getting from Labview are very poor.  I've fit this data with two different program that I trust and get roughly the same parameters from each program (I've included the good parameters below).  With labview I basically get a decent fit but the parameters are garbage.  Often only two or three parameters will optomize will the fourth parameter stays at what I input.  It seems like to get a good optomization I have to put in initial parameters that are almost the correct value.  That won't work for my eventual application.  I'll be able to fit in good starting guesses, but they won't be as close to what I seem to need right now. 

If anyone can give me some advice I'd really appreciate it.  I've included the VIs below.

 


Thanks

 

optomized with a tolerance = 1e-9

 

A=-1.99e-5

t=1.52e-5

b=0.96

c=9.9376e-7

0 Kudos
Message 1 of 9
(4,546 Views)

jsweirk,

 

I am currently working on this issue and looking over the VI's you posted (thank you for attaching your VI's with your original post!). You used LabVIEW 2012 to create these VI's? Also, what parameters do you get from the other programs you are using to fit the data?

dK
0 Kudos
Message 2 of 9
(4,501 Views)

I looked at the RMSE for the different parameter sets in your fit.

RMSE initial parameters:                    9.69E-6

RMSE LabVIEW best fit parameters: 4.40E-6

RMSE 3rd party best fit parameters:  5.50E-6

 

Below is a graph that includes the 3rd party best fit curve, and the LabVIEW best fit curve.  There seems to be a real mismatch.  Are you certain the data is the same for both fits?

 

-Jim

 

xy graph.PNG

0 Kudos
Message 3 of 9
(4,476 Views)

To reply to the first question, the initial parameters I'm using in the third party software are:

 

A=-.00005 ; t=.00005 ; b = 0.5 ; c = 0.000001 

 

 

I'm sure the data is the same.  I realize I made a mistake in copy in the third party fit parameters.  t=1.52e-4.  I'm really sorry for the mixup.  

 

 

0 Kudos
Message 4 of 9
(4,469 Views)

Thanks for those parameters.

 

Sorry, I'm still playing with your VI's to see if I can result a better optimization. I apologize for the wait.

dK
0 Kudos
Message 5 of 9
(4,419 Views)

I apologize, I have been out of office these past few weeks and have been unable to work on this. I now have time to dig back into this issue if you would like me to. Again, I apologize for the long delay as I was unavailable.

dK
0 Kudos
Message 6 of 9
(4,351 Views)

I'd still be open to any suggestions.  Thanks in advance for your assistance.

 

0 Kudos
Message 7 of 9
(4,347 Views)

I think I may have pinpointed our issue here. Again, I do apologize for the long delay. What I ended up doing was rebuilding your best fit program from scratch. I have attached the VI I created, which is nearly identical to yours. I also utilized your Streched Exponential VI as the fitting model reference. Basically, the only error you had was the settings you had for the parameter bounds for the nonlinear fit polymorphic VI. You had the minimum and maximum parameter arrays switched, which would explain the terrible best fit parameters. You can compare my VI to yours and see that the parameter bounds cluster constant is the only difference. You just removing the parameter bounds cluster constant resolves the issue.

 

With this change, I was able to get a best fit parameters in LabVIEW as:

A = -1.96792E-5

t = 0.000155122

b = 0.97666

c = 9.90572E-7

 

Hope this helps!

dK
Download All
0 Kudos
Message 8 of 9
(4,319 Views)

Thanks for that discussion.

I already gave up fitting non-linear functions with constrained parameters in Labview because it never gave me good values! After your discussion I just realized that the help function for the non-linear curve fitting might be missleading, because it states for the "parameter bounds" cluster the maximum array to be the first entry and then the minimum array. That seems to be the issue you are discussion here. 

I just change the order in cluster and fit works fine! Thanks for solving that issue maybe i could be updated in te help files!

0 Kudos
Message 9 of 9
(4,203 Views)