wrapper for the simplex fitter amoeba


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

orstats
11-11-2008, 02:55 AM
Hello:

Are there simpler examples of using NR libraries in MATLAB environment after 'introducing MATLAB to your compiler'? The tricky part is feeding the function parameters back and forth between MATLAB functions and NR functions... Thanks in advance!:o

William Handler
11-21-2008, 12:47 PM
That's pretty much the whole thing. After all, calling the numerical recipes routines in a piece of c code is very straightforward. The whole problem is one of passing the information back and forth between matlab and your c code. I am going to post an example of some of the numerical integration techniques that might help.

By the way, sorry for the delayed response, I did not recieve any email telling me that you had posted.

Will Handler