LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in Levenberg-Marquardt fit routine!

I think I have encountered a bug in the LabVIEW Levenberg-Marquardt nonlinear fit routine (vi.lib/GMath/opti.llb/Levenberg Marquardt.vi) that came with LV6i.

It appears to weigh the data points by 1 over the standard deviation squared! If I track the 'Standard Deviation' line, I encounter two places where this value is squared before the mean square error of the Y-values gets divided by it. This is to my best knowledge not right. (I found the problem after I kept getting outrageously high chi^2 values....)
0 Kudos
Message 1 of 5
(2,859 Views)

Hi

Well, this is a 20 years old post but hopefully someone will look into this.

I am wondering if this is true : I have a fitting procedure with standard nonlinear LM vi (thanks to Altenbach that posted some gaussian fitting in this forum). Anyway, my vi works fine and the fit is pretty good but the chi square (calculated with RMSE/DOF) is very large (10^8 or so). The same data fitted with other (more professional) programs gave very similar fits but with small chi2, as I expect since the fit is rather good.

Am I making a mistake in calculations or this guy is right ?

 

Thanks  

0 Kudos
Message 2 of 5
(1,062 Views)

Hi nitad,

 


@nitad54449 wrote:

 this guy is right ?


Are you still using LV6i as that guy in 2002, 21 years ago?

 


@nitad54449 wrote:

Am I making a mistake in calculations


Well, we don't know your VI.

We don't know your data.

We don't know those "other more professional programs".

 

How should we judge if you made a mistake?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 5
(1,056 Views)

Hi

Thanks for your email. I am not using LV6 (funny thing is that I think I still have it somewhere).

So, let me give more details. 

I made a vi to show an example (it may have useless things, it's just a part of a big state machine).

The fitting procedure is in ComplexFit 3zarcs.vi and the data (a simulated set) is in 3_zarcs_sim_data.txt. 

A zarc is the impedance of a capacitor and a rezistor, so a complex, it is calculated in Zarc.vi

With my program I get a very good fit (see the vi) and the reported chi2 is 99 or so. 

By using a commercial program, called ZsimpWin, I get 10^-10.

Same hing by using Zview, very small chi^2

I have no ideea why, but I believe I am making a mistake somewhere

Thanks for any suggestions

0 Kudos
Message 4 of 5
(1,047 Views)

Hi guys

Anyone know where the problem comes from ? (see my previous post with an example of the problem)

Thanks

0 Kudos
Message 5 of 5
(988 Views)