LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fit 3 peaks and an exponential background

Solved!
Go to solution

I´m pretty new at labview.

My version is 8.6

I have a spectrum with:

 

3 peaks ( I want to fit with 3 gaussians)

exponential background

 

How can I fit?

 

Thank you

 

 

0 Kudos
Message 1 of 7
(3,384 Views)

There is a shipping example called "Fit sum of 3 Gaussians with offset". You can use it as a starting point. Search for "fitting" in the example finder. 🙂

 

 

All you need to do is:

  1. modify the model to replace the offset with an exponential
  2. Adjust the number of fitting parameter estamates accordingly.
0 Kudos
Message 2 of 7
(3,381 Views)
Solution
Accepted by topic author mmlf

Thank you very much.

I will try!!!

 

Smiley Happy 

0 Kudos
Message 3 of 7
(3,353 Views)

Hello,

 

If it´s possible, I need to understand better the calculation of alpha and beta in the levenberg-marquart algoritm, present in this example.

For me the alpha is very important because the covariance. 

 

In numerical recipes C, beta=-1/2 plus second derivate of chisqr.

I can´t find the constant factor -1/2 in ABX.

I can´t find the factor 1/2 of the covariance as well.

 

When I try to understand the calculation of alpha, I´m complete lost.

Is the same equation of Numerical Recipes C (15.5.7) or a different one?

 

In "LM function and gradient" is just the gradient or second order partial derivates, I saw there order 2

 

 

Thank you very much. 

0 Kudos
Message 4 of 7
(3,303 Views)

I have not dissected the algorithm in detail, but it always seems to work well for me. You get the covariance matrix as an output, so you can treat the entire thing as a black box. 🙂 Do you have any indications that the results are incorrect?

 

For an example on how to obtain parameter errors from the covariance matrix, have a look at Jim's old post here. It shows that the results very closely match the NIST Lanczos3 test dataset, so I think it is unlikely that there is a severe numeric problem. 😉


mmlf wrote:

In "LM function and gradient" is just the gradient or second order partial derivates, I saw there order 2


 

The code itself contains several algorithms (of increasing complexity) to calculate the partial derivatives, but the selection is NOT exposed to the user. "Order 2" is the default and steps in both directions by a small increment at the cost of extra function calculations, but at the benefit of being numerically more rigorous. In a typical scenario, it does not make a real difference. The code seems easy to understand, so just open the subVIs to inspect it.

 

If you can, you should define analytical partial derivatives in your model, so all this is irrelevant anyway.

 

You could use a different partial derivative algorithm by modifying the stock code and saving it under a new name, but if you really want to do your own partial derivatives, I would recommend to leave the stock VIs alone and do things inside the model VI. Calculate your numeric partial derivatives any way you want and output them as a 2D array on the existing terminal.

 

0 Kudos
Message 5 of 7
(3,296 Views)

Hi, 

 

Thank you!

 

As I said before, I'm pretty new at labview, so I use the examples and the subVis to understand better. 

 

At this point, I have a model that I want to fit and for that, I have been studying the numerical recipes of C.

I try to understand if the "Lev-Mar-VI" use the same equations, because I need to specify in my thesis which equations I´m going to use.

"If you can, you should define analytical partial derivatives in your model, so all this is irrelevant anyway."

I already did a SubVi that calculates the partial derivates, for another model (I didn´t have the 8.6, neither the "Lev-Mar-VI").

It´s absolute necessary to define analytical partial derivates?  I really prefer not to do.

 

Thank you!

0 Kudos
Message 6 of 7
(3,269 Views)

mmlf wrote:

It´s absolute necessary to define analytical partial derivates?  I really prefer not to do.


No, if you don't define the partial derivatives, the code will automatically calculate them numerically.

 

I don't think you need to go into details referencing Levenberg Marquardt formulas. Simply state that you used the LabVIEW functions.

0 Kudos
Message 7 of 7
(3,261 Views)