William Handler
08-01-2008, 02:33 PM
Hello,
I wrote a mexfunction to run the NR simplex fitter amoeba which anyone is welcome to use, I would also appreciate any comments on how I did it, or how it may be improved.
The mexfunction is in NRFitSimplex.cpp
The mexfunction uses a class FitFunction, which is a functor that calls a user defined, in the matlab space, function. This means that it is a general fitter and can be used to fit data with any user defined function of choice. The function that amoeba actually minimizes is the chi squared function for the data and the fit function.
I added a further wrapper in matlab, FitSimplex.m to do a plot of the fit, a picture being worth a thousand words.
I tested the code using a Gaussian function and it works quite nicely giving good fits. The only thing I have not figured out yet is how to extract the errors on the fit parameters.
Overall it acts like it should, I now have a fairly simple function I can call from the matlab environment to fit data with. I am using this example as a basis for further matab wrappers to numerical recipes code, so any things I could do better let me know.
I am including all the relevant files in attachments hopefully.
Looking forward to some feedback,
Will
I wrote a mexfunction to run the NR simplex fitter amoeba which anyone is welcome to use, I would also appreciate any comments on how I did it, or how it may be improved.
The mexfunction is in NRFitSimplex.cpp
The mexfunction uses a class FitFunction, which is a functor that calls a user defined, in the matlab space, function. This means that it is a general fitter and can be used to fit data with any user defined function of choice. The function that amoeba actually minimizes is the chi squared function for the data and the fit function.
I added a further wrapper in matlab, FitSimplex.m to do a plot of the fit, a picture being worth a thousand words.
I tested the code using a Gaussian function and it works quite nicely giving good fits. The only thing I have not figured out yet is how to extract the errors on the fit parameters.
Overall it acts like it should, I now have a fairly simple function I can call from the matlab environment to fit data with. I am using this example as a basis for further matab wrappers to numerical recipes code, so any things I could do better let me know.
I am including all the relevant files in attachments hopefully.
Looking forward to some feedback,
Will