LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between levenberg marquardt.vi and nonlinear lev-marq.vi

I'm just wondering what the difference is between these two VI's. On the help file they seem to have the same descriptions.

Basically I'm trying to improve on altenbach's 3D polynomial fitting program. I tried some error analysis on the predicted data (use the polynomial equation, input X & y, then compare to the known values) but it seems that there is quite a big of error. From the graph it doesn't seem like the program is doing a proper least squares fit. The 2D fit lines seem to go through middle of the data points instead of doing a least square fit. I'm not too sure what's causing this but perhaps it's not finding the minimiums correctly?

So basically I'm looking into perhaps a different way to find the polynomial coefficients but need some helps badly. 😞
0 Kudos
Message 1 of 10
(3,944 Views)
Here's my error analysis. (Ignore chart1 and sheet1).

Idealy the WW vs del WW and % moisture vs del % moisture should have relatively flat curves.
0 Kudos
Message 2 of 10
(3,941 Views)
They are similar. The difference is the way the model is provided.

(1) Levenberg Marquardt.vi uses a model description as a cluster containing the fitting equation.

(2) Nonlinear lev-mar Fit.vi uses a classic subroutine for the model.

My version is modified from (2), but calls the model function subVI via "call by reference node". This way it is easier to switch between models without having to modify all the VIs.

Message Edited by altenbach on 06-28-2005 05:17 PM

0 Kudos
Message 3 of 10
(3,940 Views)
Thanx for the reply. Any idea how I might be able to make the 3D fit a bit more accurate?

Basically right now if you look at the graph screen, the 2D fitted curve (red) isn't actually a least squares fit. Instead it's going through the centre of each data set curves. (Unless there's some concept I'm missing here...)

It appears that the 1st fitted curve will always have the 2D fitted curve going through the centre of the data set curve (ie removing the 2% array and only using 50%, 75%, 99%).

???
0 Kudos
Message 4 of 10
(3,926 Views)
One more thing, it turned out I actually need the cross terms. Is there any way to implement these terms?
0 Kudos
Message 5 of 10
(3,923 Views)
OK, the cross terms seems to make all the difference. A polynomial order of 4 seem to be great with the data built into the VI. (You added an empty line in the first two data strings, causing some extra zero values. I fixed this too.) I did not test with the new data from the xls file, so please try.



Here's the mse for the various highest polynomial orders:
0: 889.265 (1 term)
1: 60.3489 (3 terms)
2: 8.61332 (6 terms)
3: 1.35049 (10 terms) <--- pretty good.
4: 0.02867 (15 terms) <--- optimal!
5: 0.01826 (21 terms) <--- not worth the improvement.
6: 0.02656 (28 terms) <--- getting worse

I have converted the VI to LabVIEW 6.1, but I cannot test, because I currently don't have 6.1 installed (only 7.0+). The algebra VIs seems to have gotten significant improvements, and the fitting is much more reliable in LabVIEW 7.1. Even in LabVIEW 7.0, it blows up above order 3 using SVD algorithm, but it works with Cholesky. If the fit fails, try to play with some of the other algoritms.

Message Edited by altenbach on 06-29-2005 06:10 PM

Download All
0 Kudos
Message 6 of 10
(3,911 Views)
Of course you don't really have enough data in the reflectivity dimension to justify higher orders.

(For the graphs below, I am using a 3D graph with 2 plots:
(1) 3D curve with the raw data (dots)
(2) 3D Surface with a grid of generated data from the best fit coefficients.
I also show a 3D cursor locked to plot 2.)


For example with Polynomial order=4, a full 3D graph from the coefficients looks pretty good.




However, if you would do a 7th order fit on the same data, the fit gets better but the full plane looks not very reasonable. 🙂

Message Edited by altenbach on 06-30-2005 12:39 AM

Download All
0 Kudos
Message 7 of 10
(3,904 Views)
I'm not 100% suue how the math works in the program. My impression is that if you have 4 curves, fitting a 4th order 3D polynomial would essentially give you 0 errors. Is this correct?

I've tried doing the same thing but instead of doing a 3D polynomial fit, I did 2 2D polynomial fits in xz (WW vs reflectivity), obtained bunch equations, plugged back in the reflectivity value into the equations and compare the real WW values with the predicted WW values. This way of analysis is pretty accurate but it's not exactly what I want. (Want a 3D polynomial equation).


0 Kudos
Message 8 of 10
(3,881 Views)
bump!
0 Kudos
Message 9 of 10
(3,875 Views)
Story continues HERE. 🙂
0 Kudos
Message 10 of 10
(3,834 Views)