
Find local minim of a xhi2 by optimization

Erik_Kran
Hi,
I need to minimize a chi2, calculated from an experimental spectrum and a calculated spectrum.
I've thought about using Optimize, but the function must be an Igor user function. I understood it should be written in the form (it is just an example):
Function calc_spectrum(w,x) : FitFunc Wave w Variable x return w[0]+w[1]*(x-w[2])^2 etc..... End
But their is no parametric equation in my case, the final spectrum cannot be expressed in a simple way as a function of x (wavenumber) and w[i] parameters.
Is there a way to use the Optimize command? Otheriwse, is there another way? Does Igor or users propose packages with optimizing algorithm, for instance like those proposed in the Pygmo package? (https://esa.github.io/pygmo/)
Thanks in advance.
This function form is for FuncFit (curve fitting, FuncFit will then automatically create a chi2 function based on the model and data and minimize it). Optimize is more general since it only needs the objective function that is to be minimized, so you have to write your own chi2 function but otherwise Optimize doesn't need to know how the model and data are manipulated.
That said I had a look on the pygmo link you give and it seems they use quite different approaches : the methods they mention, like PSO or DE, are evolutionary algorithms which scan the configuration space to try to find a global minimum, in contrast gradient-based iteration methods such as most of those used by Optimize (at least as of Igor 8 I'm using) will stop at the first local minimum encountered.
You might have a look at this project where DE is implemented and explainded in more details : Fast Fitting with GPU acceleration | Igor Pro by WaveMetrics (the GPU part is an option, you can use the package with Igor code only).
May 13, 2025 at 11:11 pm - Permalink