|
# Scientific Computing with Python |
|
|
|
## Why Python? |
|
|
|
* Programming is fun again! |
|
* Free (as in beer and as in speech) |
|
* Steep learning curve |
|
* Highly readable, easy to code |
|
* Batteries included |
|
* Package management |
|
* Scales pretty well (ie. namespaces, proper OO) |
|
|
|
### Difference to Matlab |
|
|
|
* Indexing starts at `0`, not `1`. Look: |
|
|
|
## When to use |
|
|
|
### Use Matlab when... |
|
|
|
* you only do throw-away scripts |
|
* you need to build GUIs to interact (but don't need to deploy them) |
|
* you want print-ready graphs |
|
|
|
### Use R when... |
|
|
|
* you do data analysis, and data analysis _only_ |
|
|
|
### Use python when... |
|
|
|
* you want code that scales well with your project |
|
* you collaborate with others on the code |
|
* you want parallel computing, Sockets, interface C, C++ or Fortran, |
|
* you want to [parse a string](http://www.youtube.com/watch?v=1lBeungEnx4&t=5m9s) |
|
|
|
## Setting up your Environment: |
|
|
|
* We'll need python, ipython, matplotlib, numpy, scipy and PIL (the python image library) |
|
* For nerds: |
|
* install python2.7 |
|
* install pip (`curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python`) |
|
* using pip, install the other stuff (ie. `pip install matplotlib`) |
|
* Alternative distributions (haven't used any of them): |
|
* [Spyeder](http://code.google.com/p/spyderlib/) |
|
* [Enthought Python](http://www.enthought.com/products/edudownload.php) |
|
* [Sage](http://sagemath.org/) (Supports symbolic computation, not 100% python compatible though) |
|
* [Python(x,y)](http://code.google.com/p/pythonxy/wiki/Welcome), Windows only |
|
* At any rate, we can the interactive ipython console with `ipython qtconsole --pylab inline` |
|
* I we feel fancy, we'll run the console in the browser: `ipython notebook --pylab inline` Why? |
|
* Everything you do is saved automatically. |
|
* Start it from a folder in your dropbox and you have the same environment on all your machines |
|
* You can even tell your code cells to be just Markdown-Formatted text-cells. This way you can annotate your code, log results, etc. A proper lab book! |
|
|
|
## Further Reading: |
|
|
|
* [Numpy for Matlab Users](http://www.scipy.org/NumPy_for_Matlab_Users) |
|
* Cheat [Sheet for Matlab](http://mathesaurus.sourceforge.net/matlab-numpy.html) and [R users](http://mathesaurus.sourceforge.net/r-numpy.html) |
|
* The Excellent [SciPy Lectures](http://scipy-lectures.github.com) |
|
* Some interesting [matplotlib recipes](http://www.scipy.org/Cookbook/Matplotlib) |