Curve Fitting
Cory K
I was told by a colleague to fit the data to an "80% Gaussian, 20%Laurenzian" fit.
So far, I am able to fit something to a guassian fit, and to a laurenzian fit, but not a mix of the two.
First of all, is that even mathmatically possible? If so, how do you do it on Igor?
Yes, it is mathmatically feasable, I was misinterpreting the sentance.
What they meant was the following:
y = y value
G(x) = function of Gaussian curve
L(x) = function of Laurenzian curve
I think I need to fit the data to:
y = 0.8*G(x) + 0.2*L(x)
could someone tell me how to do this?
September 17, 2008 at 02:55 pm - Permalink
September 17, 2008 at 02:57 pm - Permalink
I would like something more along the lines of "multifunction fitting" if that exists somewhere
September 17, 2008 at 03:03 pm - Permalink
I created a new fit called GaussLorMix:
f(x) = 0.8*(y0 + A*exp(-((x-x0)/width)^2)) + 0.2*(y0 + A/((x-x0)^2 + B))
where:
Independent variable = x
Dependent variables:
x0
y0
A
B
width
However, since it is a custom fit, I must provide initial guesses for each of the values.
If I were to provide guesses, they would be exactly that.... guesses
Any advice?
September 17, 2008 at 03:31 pm - Permalink
DisplayHelpTopic "Fitting to a User-Defined Function"
September 17, 2008 at 08:43 pm - Permalink
You might want to check if your colleague meant that you should fit with a Voigt peak shape, which is a convolution of a Lorenzian peak with a Gaussian peak. The 80/20 split would be a shape parameter of 4, where the shape parameter is the ratio of the Lorenzian width to the Gaussian width.
Igor ships with an XOP called the MultiPeakFit xop that implements a Voigt peak function.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
September 18, 2008 at 03:54 pm - Permalink
1) the Y0 parameter should appear only once, outside the sum. The way you've written it won't cause a problem, but it's inefficient.
2) You need the widths of the Gaussian and Lorenzian peaks to be the same, presumably. So you need to use just the B parameter (full width at half max of the Lorenzian) and set width = 2*sqrt(ln(2))*B. I think I have that right...
3) You could use the built-in Lor fit, then use the parameters from that fit as the initial guess for your combined fit.
4) Oh, yeah- you can also take the A outside the sum. So the final equation will be something like
Variable gwidth = 1.6651092223154*B
f(x) = y0 + A*(0.8*exp(-((x-x0)/gwidth)^2) + 0.2*(y0 + A/((x-x0)^2 + B)))
Where the fit parameters are y0, A and B.
By the way, there is just one dependent variable here; it is the result of evaluating the equation. The things called y0, A and B are "fit coefficients". X is the independent variable.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
September 18, 2008 at 04:09 pm - Permalink
I'll give that a shot
September 19, 2008 at 12:12 pm - Permalink
April 10, 2010 at 02:48 pm - Permalink
Go to your Igor Pro folder (a quick way to find it is to use Igor's Help menu). In the More Extensions folder, find Curve Fitting->MultipeakFit.xop. Make an alias or shortcut to that file in the Igor Extensions folder. Re-start Igor. Note that there is a help file in the same place as the .xop file. It has documentation for the functions defined in the XOP file. You can open that file easily in Igor using this command:
DisplayHelpTopic "Voigt"
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 12, 2010 at 10:06 am - Permalink
Function Fitting_peaks(Data_y, Data_x, Funcs_fitting, coefs)
Wave Data_y, Data_x, coefs
String Funcs_fitting
String test
test = "{" + Funcs_fitting + "," + "coefs}"
FuncFit {String=test} Data_y /X={Data_x}
End
I executed the function like Fitting_peaks(wave_y0, wave_x0, "gauss", coef) and I got a error message "parameter wave was null or missed". Could somebody help to point out the error in the function? Thanks in advance.
April 13, 2010 at 05:20 am - Permalink
The error suggests that the wave reference "coefs" doesn't correspond to an actual wave that exists at run-time. Did you create a wave called "coefs" in the current data folder?
Perhaps if my suggestions don't help you figure out the solution you should send us a copy of your experiment file (the .pxp file) to support@wavemetrics.com.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 13, 2010 at 09:04 am - Permalink
Thanks for your reply. That is exactly what I am doing now. I started from single function to simplified debugging. I tried the sum of functions form of FuncFit with single function in command line and it worked. I did the check you mentioned before I posted my question. I found it worked if I directly used the coefficient wave instead of passing it through function interface.
Should I address the email directly to you?
Yu-Hung Lien
April 13, 2010 at 03:17 pm - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 14, 2010 at 08:47 am - Permalink