How do I fit this curve with a polynomial function?
Igor_user
I'd like to fit the attached curve with a polynomial function.
It's a bit awkward with the hump at around 0.1 in the x-axis. But the idea is to carry out a best auto fit of a polynomial to that curve, and then subtract the data of the polynomial fit by the data of the curve, so that all I left with is the data of the hump which is what actually contains the information I want.
Does anyone know how to do an auto fitting for this?
Regards,
http://www.ncnr.nist.gov/programs/sans/data/data_anal.html
Or Irena:
http://usaxs.xor.aps.anl.gov/staff/ilavsky/irena.html
Hope there's something useful in there.
June 28, 2012 at 02:12 am - Permalink
I would have a go with the
CurveFit
opertation, for information executeDisplayHelpTopic "Curve Fitting"
from the command line. To start with you could try using the curve fit dialogue by selecting Analysis > Curve Fitting. Here you will probably have to play around for a while to get a feel for the coefficients before implementing in a procedure. Using the poly n keyword you can fit a polynomial with n terms to your curve. Using the /K flag you can specify fixed values for the coefficients or /C=constraintSpec flag you can specify constraints for the coefficients if you want them to be limited to a certain range. ExecuteDisplayHelpTopic "Fitting with Constraints"
from the command line to learn more about that. The /M=maskWave flag would probably be very useful, here you can make a mask wave to exclude points i.e. your peak, from the curve fitting for the polynomial. All of these options are available from the dialogue too.After you have been able to fit a polynomial to the background, if you specify that the fit wave should have the same number of points as the input wave you can subtract the polynomial background from the data then fit the peak. All of this can be automated but you would obviously want to have breaks for the user to specify that they are happy with each part of the fit.
June 29, 2012 at 03:29 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
June 29, 2012 at 09:07 am - Permalink
I manually removed the hump and smooth the data to make it more like a polynomial curve.
I didn't apply any constraint. I put 'none' for that option and gave some initial values for the coefficients e.g.
K_0=105
K_1=-20
K2=-10
But it returns a message (attached). In this case, can Igor actually do a best square fit to adjust the parameters values?
Regards,
July 4, 2012 at 09:24 pm - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 5, 2012 at 04:07 pm - Permalink