- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- ソース を表示
- PythonForScience へ行く。

注) このページは色々考えて英語にしました。

Matlab sucks because it is too expensive for students and even for professional researchers who have not enough funding (like me :-). Actually, Mathworks offer a cheap student version of Matlab+some toolboxes for $200 or so. Therefore, the financial problem is more serious for researchers like me. That was the main motivation for me to start exploring possibilities of using Python as a replacement for Matlab. Over the past few months, I did some investigations and tests on Python and concluded that Python can be a replacement of Matlab in most cases, as far as my needs are concerned. Moreover, I found that Python surpasses Matlab in many aspects, so it is not just a Matlab replacement but much more. Now I'm migrating from Matlab to Python rapidly. This page is intended to be a place to dump some know-hows on using Python as a scientific/technical computation platform.

Want to know what the heck is Python ? Read Wikipedia

It is very important for me to prepare a comfortable and efficient working environment before using a programing language. Python can be used in various ways. Python's core is its interpreter. So you can write a program using your favorite editor and pass the file to the Python interpreter. However, this may not be the best way to do scientific computation. While you are examining your experimental data and tweaking it, interactive session is often useful and powerful.

Matlab provides such a capability through its own IDE (Integrated Development Environment). Python interpreter can also be invoked in interactive mode, but it is not that useful by itself. There are several Python IDEs which provide similar look & feel to the Matlab IDE. IDLE is a python IDE distributed with the standard python package. Wikipedia has a list of Python IDEs. You can choose whichever one you like to do your Python programing.

As for myself, I don't like those IDEs for not well defined reasons. My default editor is Emacs and I feel comfortable doing everything in Emacs. So I decided to use Emacs as my Python development environment. Actually, I used to use Matlab from Emacs. Therefore, using Python through Emacs is a natural move for me.

A nice feature of Matlab standard IDE is the cell. You can divide a script into several parts (cells) by putting dividers (%%) in the file. Then you can execute each cell by pressing Ctrl-Enter with the cursor in a cell. This way, you can execute a small portion of a long script without executing the whole script. This is useful, for example, when you have a long calculation and just want to change the appearance of the plot at the end.

I also like the cell of Mathematica notebook, where you can have nested (hierarchical) cells. You can also open and close cells to improve the readability of a long script.
I don't know if any of the Python IDEs listed in the Wikipedia page has such a functionality but I knew that with Emacs, you can easily create such a function using Emacs Lisp. Therefore, I added a cell functionality to python-mode.el. If you are interested in my Emacs-Python environment, read this.

The above tutorial applies mainly to linux users, but Windows users should be able to do the same thing, in principle, as Emacs now works fine on Windows. I don't know anything about Mac, but Carbon Emacs may work.

For Windows users, there are two easy ways to install Python and scientific extensions at once without a hustle. One is Enthought Python Distribution (EPD) and the other one is python(x,y). EPD is also available for Mac, Linux and Solaris. python(x,y) is available for Linux too. EPD is basically a commercial distribution. However, you can use it for free if you are in an academic institution. python(x,y) is free for everyone.

- Python itself
- Python Documentation Index Official Python Documentation. It includes a tutorial and library references.
- Dive into Python This is a nice introductory book for Python. Available in html and PDF.

- Numpy & Scipy
- Scipy.org The portal for Numpy&Scipy related resources.
- Guide to Numpy An extensive reference book of Numpy by the author of Numpy, Travis E. Oliphant.
- Numpy & Scipy documentation Tutorials and references for Numpy and Scipy.
- Additional Documentation Other tutorials and references for Numpy and Scipy.
- Numpy for MATLAB users This is a useful comparison table of MATLAB and Numpy functionalities.
- Cookbook A collection of examples for Numpy and Scipy.

- Matplotlib
- Official web page It includes detailed tutorials and API references as well as an extensive collection of examples.

- IPython
- Official web page
- A Demonstration of the 'IPython' Interactive Shell A very nice video tutorial. You must watch it.

- Other
- Scientific and parallel computing using IPython A nice vide tutorial series on how to use Python for scientific computing including parallel computing.
- ShowMeDo This site includes many useful video tutorials for Python and other computer languages/softwares.
- Scipy2009 Conference An annual conference on scientific computing using Python. It includes slides, videos and proceedings from the previous year conference. There were introductory tutorials and advanced tutorials given in the conference. All the videos and slides are available online. Very nice.
- Enthought A sponsor company for Numpy&Scipy. They have monthly webinars of Python for scientific computing.
- Open source tools by Enthought There are number of useful tools Enthought developed to use primarily for their products and released open source.