H wrote:
>
> Since I got such good feedback on my search 1D array problem on this
> group, I thought I would post this question. I am looking for a
> guassian fit and from searching this group, NI's dev zone, and the
> webring there is nothing to be found but others looking for the same
> thing. If anyone has any suggestions about how to fit data to a
> gaussian curve or has found a vi for this, I and I am sure many
> others, would appreciate the heads-up. I am not sure how to approach
> it as this is my first attempt at fitting data.
>
> BTW, I have tried the labview.pica.army.mil site and its says there is
> an archived copy of an attempt somewhere but the links that lead to it
> are bad and any all the alterations I try don't work either. If
> anyone knows the correct links, that would be appreciated as well.
>
> You guys are great
> Heather
Heather,
I have done this in the past, but my VI's are not general enough to
pass on. I can explain the general approach I used: I modified the
existing Non-Linear Lev-Mar Fit VI's. This set of VI's will fit an
arbitrary analytical non-linear function. There is one sub-vi in which
you need to provide the analytical expression and the expression of its
derivatives with respect to the fit parameters. This all works fine,
except that for a function like a Gaussian, you need to supply fairly
reasonable first estimates for the initial coefficients or the fit will
quickly diverge. My data is almost always a relatively well-behaved
(but noisy) Gaussian peak, so I was able to generate estimates
relatively easily. I wrote the Gaussian equation so that the fit
parameters were explicitely the peak amplitude, position, width, and
offset. I estimated these with relatively straight-forward calculations
from the raw data. For Amplitude, smooth the data and find the maximum
value in the data array. The index of that maximum is a good first
estimate of the position. For offset, average a bunch of data well
before and well after the peak. The width is just found by searching
the array forwards and then backwards for where it exceeds half the peak
amplitude and subtracting the two indeces.
If there is a lot of demand for this, I could try polishing it up and
posting it. It would take a while, but I could be motivated to do it,
since I have another project coming up for which I need to do it anyway.
Regards,
Dave Thomson
-------------------------------------------------------------
David Thomson 303-499-1973 (voice and fax)
Original Code Consulting dthomson@originalcode.com
www.originalcode.com
National Instruments Alliance Program Member
-------------------------------------------------------------
Research Scientist 303-497-3470 (voice)
NOAA Aeronomy Laboratory 303-497-5373 (fax)
Boulder, Colorado dthomson@al.noaa.gov
-------------------------------------------------------------