Question

I have been an IDL programmer for sometime now and looking to transition to Python. I find that MPFIT's IDL version exists in Python. However, I am looking for MPFITFUN version in Python (http://www.physics.wisc.edu/~craigm/idl/down/mpfitfun.pro) or something similar.

Basically, I am looking for a Python function that takes a user-defined function and uses like Levenberg-Marquardt least-squared fit (like MPFIT).

Thanks,

Was it helpful?

Solution

There are fitting functions built into SciPy but I do not know of any which account for uncertainties in data as MPFITFUN does. I have found Sherpa to be an excellent modeling and fitting package for Python which accounts for uncertainties and replaces MPFITFUN: http://cxc.harvard.edu/contrib/sherpa/

Since Sherpa is produced by astronomers it has a lot of built in astrophysical models, but you can build your own function to fit with Sherpa's Levenberg-Marquardt, Nelder-Mead or Monte Carlo algorithms. I used the template from the pysherpa blog: http://pysherpa.blogspot.com/2010/06/user-defined-sherpa-model-types-using.html

OTHER TIPS

I accidentally found that there also exists the MPFITEXPR in Python. Here's the link to the code. You can also download it via Astrolibpy project.

Link:

https://code.google.com/p/astrolibpy/source/browse/mpfit/mpfitexpr.py?r=3545675a0662392e3e09c88beaf275c9e7881cf6

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top