User-specified function in mpfit - least-squares

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,

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

mpfit.py is available from https://code.google.com/p/astrolibpy/ and an older version hosted at http://cars.uchicago.edu/software/python/mpfit.html.
A good alternative is lmfit: https://pypi.python.org/pypi/lmfit/, https://github.com/lmfit/lmfit-py, http://lmfit.github.io//lmfit-py/

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

Related

how to solve a determinant in symengine (python) explicitely with the berkovitz algorithm

I would like to replace an existing sympy code with symengine and I would need to replace the determinant calculation (method=berkovitz) with symengine. Is it possible to select this method explicitely with symengine in python? I saw it in the c++ code but I do not know how to use it in the python environment. I am using the latest symengine version (v0.9.2).
I looked into the testcases for matrices but could not find an example. I just wonder because the method is mentioned in the c++ code of symengine and I thought it should also work from python.
Thanks for any hint.

Tensorflow Documentation

I am increasingly irritated and frustrated by the Tensorflow documentation. I searched on google for documentation regarding
tf.reshape
I'm getting directed to a generic page like here. I want to see the details of tf.reshape and not the entirety of the documentation.
Am I doing something wrong here?
Do not Google about Tensorflow documentation, use the TensorFlow Python reference documentation and ctrl + f
The probably fastest way is to use the Tf documentation is:
http://devdocs.io/tensorflow~python/
Just type tf.reshape and you are done.
which can be also used offline and automatically updates the docs.
edit: even typing only res shows you the documentation.
Update for posterity:
With the new TensorFlow, the website is now indexed with Google, and it should also soon be indexed by other search engines.
I would suggest you use the GitHub repo as your documentation instead. https://github.com/tensorflow/tensorflow/tree/master/tensorflow/g3doc/api_docs/python/functions_and_classes
For example tf.reshape is in a single Markdown file https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/api_docs/python/functions_and_classes/shard0/tf.reshape.md
To search for the document you want, you could use the GitHub search under that functions_and_classes folder.
An example is
tf.reshape() path:tensorflow/g3doc/api_docs/python/functions_and_classes language:Markdown
https://github.com/tensorflow/tensorflow/search?utf8=✓&q=tf.reshape%28%29+path%3Atensorflow%2Fg3doc%2Fapi_docs%2Fpython%2Ffunctions_and_classes+language%3AMarkdown&type=Code
which search for tf.reshape() under the documentation folder.
I use the non-official Dash/Zeal docset for TensorFlow:
https://github.com/ppwwyyxx/dash-docset-tensorflow
It is a very convenient way of browsing the TensorFlow documentation offline and it solves the problem you are describing.
Is this what you are looking for? Using the search functionality of the browser helped me find it.
I suppose that you have installed tensorflow in your computer and that you know the name of function that you may want to use.
So if you use some Python IDE, I think you can directly jump to the declaration or definition of this function and see the usage and explanation. That is the same documentation as online (although for some functions it is not very clear).
You can use the url for tensorflow documentation and add what you want to search..
The base url is:
https://www.tensorflow.org/api_docs/python/tf/
You can add what_ever_you_want_to_search after the /
Since Tensorflow r1.1 a search on google for items like 'tf.shape' now lists the appropriate page at the top of the search results.
This didn't work back in r0.10 and r0.11, maybe because there were many markdown formatting issues in the Tensorflow docs themselves.
Since you tf is developing best way is to go through the tf API. And it's good if you can follow these slides in http://web.stanford.edu/class/cs20si/

Is there any good tutoria or reference for writing code with Magma?

Currently I am trying to use Magma to do matrix operation on GPU, however, I found few documents about it. The only thing I can refer to is its testing program and the online generated document(here), which is not convenient to use. And the user guide seems outdated.
If you look here, getri and potri are supported.

How to use CUTThread in CUDA

I am trying to run my own multi-gpu example, and I am following the NVIDIA's example. However, I cannot find where CUTThread is defined and then the compiler says:
error: ‘CUTThread’ was not declared in this scope
The short answer is 'dont use cutThread at all'. It comes from the SDK, not the toolkit, and it not intended for general use - NVIDIA don't document any of these function, nor do they guarantee that they either work, or won't change in definition or function from release to release. If you are interested in multiGPU computing, have a look at this answer to a very recent Stackoverflow question.

Where can I browse the sourcecode for libc online (like doxygen)

Sometimes I want to look up the implementations of functions in the stdlib, I've downloaded the sourcecode, but it's quite messy.
Just greping is not really suitable because of the many hits.
Does anyone know a webpage doxygen style that has the documentation.
The same goes for the linux kernel.
Thanks
You should check if your distribution is using the vanilla GLIBC or the EGLIBC fork (Debian and Ubuntu have switched to EGLIBC EDIT: they switched back around 2014).
Anyway, the repository browser for GLIBC is at http://sourceware.org/git/?p=glibc.git
http://code.woboq.org/userspace/glibc/, posted by #guruz below, is a good alternative.
The source is a bit complicated by the presence of multiple versions of the same files.
How about this for libc documentation? And perhaps this for the kernel? There is also Google Code search; here is an example search.
More on Google Code Search You can enter search queries like this: package:linux-2.6 malloc for any references to malloc in the linux-2.6 kernel.
Edit: Google Code search is now shut down. But you can access the git repo at http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git and it has search as well.
You can try http://code.woboq.org/userspace/glibc/
It has nice navigation/hilighting similar to an IDE.
To help navigate the source to glibc, perhaps try something like ctags or cscope?
Note: I get dumber every time I look at the glibc source, so please be careful! :)
If you are using GNU C (glibc), the functions (beyond the GNU extensions) follow the POSIX standard as far as their arguments, implementation, failure and return values. If you want to peek under the hood of static members, you'll have to look at the code.
Every push (that I can remember) to try and adopt something like Doxygen for glibc was rejected for the following reasons:
Redundant, POSIX already documents almost everything thats exposed, as well as man and info pages.
Too much work initially
More work for maintainers
As far as the kernel goes, Linux does use a system very similar to Doxygen called Kerneldoc.
You can also get actual Doxygen-generated docs from http://fossies.org/dox/glibc.