Fitting data with Python

I’ve recently become a heavy user of the numerical capabilities of Python. I’ve written about my experiments before, but now I’m writing production quality code with numpy and matplotlib.

Mobility Temperature Plot

The above is an actual plot that I created for some Hall measurements I was doing. I was supposed for find functional relationships between temperature and majority charge carriers, which in my case were electrons because of the n-type doping. The simple case was a least squares fit: scipy.optimize.leastsq to the rescue. The more complicated part was solving a non-linear equation for roots and then doing a least squares fit. The root-finding module in scientific python provides lots of options. At this point, I can confidently say that this environment has more features than Octave.

Just today, I wanted to use the Fourier method on a differential equation (plug: the advantages of which are here) and numerical python with fft, fftshift and fftfreq are exact substitutes for their Matlab equivalents. You can also put actual LaTeX equations on plots, which is a major plus.

That is all.

Possibly related:

Leave a Reply