LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nonlinear curve fitting and convolution

Hi,
I am interested in fitting some data (intensity as a function of time) to a sum of exponentials convolved with a gaussian instrument response function (IRF). I will use the Nonlinear Curve Fit LM instance of the Nonlinear Curve Fit VI and therefore intend to provide a model VI with the right connector pattern that provides an array containing the model (decay convolved with IRF. But ... I think that the model will change with each iteration of the least squares search not only because the parameters a in f(X,a) change (the normal situation) but also because of the convolution with the gaussian IRF. How do I get the levenberg Marquardt routine to feed the parameters a back into the model calculator for each iteration. Or am I missunderstanding something fundamental here.
Thanks so much
-nd
0 Kudos
Message 1 of 11
(5,376 Views)


Wheels wrote:
Or am I missunderstanding something fundamental here.

Possibly. 🙂
 
All your model function needs to do is calculate the model function based on [a, x, and possibly additional information via the data variant input].
 
All you need is to ensure that the output of the model calculation has the same number of points as the data array to be fitted so a 1:1 comparison can be made.
The Levenbert-Marquardt algorithm will do the rest. Starting with a reasonable set of starting values for [a] it will find the best combination of parameters such that the model calculation best matches the experimental data.
 
Is the IRF fixed (gaussian width) or itself a variable that can be fitted? 
Maybe I don't uderstand. Can you attach an example of your model?
0 Kudos
Message 2 of 11
(5,373 Views)
Dear Altenbach,
THanks for your reply. Let me ask it a different way before I send anything. Suppose my model is calculated with a vi that does an integral. In other words it is not just a formula with parameters. Will the Levenberg Marquardt routine run that vi that calculates the model for each iteration of the non-linear fitting routine?
THanks

0 Kudos
Message 3 of 11
(5,339 Views)


Wheels wrote:
Suppose my model is calculated with a vi that does an integral. In other words it is not just a formula with parameters.
Sorry, I don't quite understand what you mean by that.
 
Do you mean the lineshape is a running integral of another function? As long as the data is an equivalent integral function, you should be fine.
0 Kudos
Message 4 of 11
(5,332 Views)
Hi
My model function is a convolution of the exponential decay function (independent variable t with parameters a) and the gaussian IRF (also containing t). The model is calculated by doing a convolution integral (I found a labview vi to do it). Again my concern is that the integral may need to be done each iteration of the fit since the model is not a simple formula that depends on t and a.
Thanks
0 Kudos
Message 5 of 11
(5,326 Views)


Wheels wrote:
My model function is a convolution of the exponential decay function (independent variable t with parameters a) and the gaussian IRF (also containing t). The model is calculated by doing a convolution integral (I found a labview vi to do it). Again my concern is that the integral may need to be done each iteration of the fit since the model is not a simple formula that depends on t and a.

The convolution just needs to be part of the model subVI. Some of my functions involve multiple convolutions and I have never had any problems.

 
0 Kudos
Message 6 of 11
(5,323 Views)
thank you very much
0 Kudos
Message 7 of 11
(5,320 Views)

Hi there,

I am working on a VI which takes in account an IRF by a Gaussian function but I am facing the problem of convonlution. I am using the same non linear method discussed here except the model that I am using is not good because the convolution VI doubles the lenght of my vector!! how can I solve my problem? I attached here the VI that I am using as model.

 

Thanks a lot

0 Kudos
Message 8 of 11
(4,391 Views)

(Sorry, posting by phone and cannot look at your VI).

 

Why can't you simply take the appropriate array subset before returning the model?

I typically implement a simple circular convolution where the size remains the same, but you might get some wrapping, depending on the data.

0 Kudos
Message 9 of 11
(4,386 Views)

Thanks a lot for your quick reply, and I have to say that I am new to labview. I am discovering now this tool and honestly I also did not know about the circular convolution..(I have to study it). However, a quick solution would be a benefit.

0 Kudos
Message 10 of 11
(4,382 Views)