Introduction to computing and programming in python and matlab
Python is a modern language used extensively by Google and NASA, as well as many others. Like Matlab, it also has an interactive structure, clean syntax, and the ability to interface with fast compiled languages, like C. There are modules in Python for doing numerical work and visualization, and thus one can make a Python-based computational environment with much the same feel as Matlab. Python is also free, is far more versatile, and can be used in many more applications than Matlab, including robotics, web frameworks, text processing, and others. It is particularly good as a first language, and I have found it personally very useful in my classes.
This Faculty Development Seminar uses a “how-to” approach to setting up Python as a computational environment, geared towards current users of Matlab or similar environments. It explores specific applications of numerical computing, and highlights the power of using Python both in research and in teaching. The seminar will explore my own experiences of the past year, converting from a die-hard Matlab fan to a Python enthusiast.
Introduction
Comparison with Matlab
Advantages
Extensions with Pyrex
Communication
Conclusions
Matlab is a commercial program used extensively in the scientific and business communities. There are many reasons why it is very popular, including its interactive structure, clean syntax, and ability to interface with fast compiled languages, like C. It also has many routines for signal and image processing, optimization, and visualization.1980-1988: The BASIC Years
1989-1993: The Pascal Years (with a little Fortran)
1994-1996: The C/C++ Years
1995-2006: The Matlab Years (with C for cmex)
2003-2006: The Disenchantment Years
2006-present: The Python Year(s)
1980-1988: The BASIC Years
1989-1993: The Pascal Years (with a little Fortran)
1994-1996: The C/C++ Years
1995-2006: The Matlab Years (with C for cmex)
2003-2006: The Disenchantment Years
2006-present: The Python Year(s)
1980-1988: The BASIC Years
1989-1993: The Pascal Years (with a little Fortran)
1994-1996: The C/C++ Years
1995-2006: The Matlab Years (with C for cmex)
2003-2006: The Disenchantment Years
2006-present: The Python Year(s)
1980-1988: The BASIC Years
1989-1993: The Pascal Years (with a little Fortran)
1994-1996: The C/C++ Years
1995-2006: The Matlab Years (with C for cmex)
2003-2006: The Disenchantment Years
2006-present: The Python Year(s)
1980-1988: The BASIC Years
1989-1993: The Pascal Years (with a little Fortran)
1994-1996: The C/C++ Years
1995-2006: The Matlab Years (with C for cmex)
2003-2006: The Disenchantment Years
2006-present: The Python Year(s)
1980-1988: The BASIC Years
1989-1993: The Pascal Years (with a little Fortran)
1994-1996: The C/C++ Years
1995-2006: The Matlab Years (with C for cmex)
2003-2006: The Disenchantment Years
2006-present: The Python Year(s)
1980-1988: The BASIC Years
1989-1993: The Pascal Years (with a little Fortran)
1994-1996: The C/C++ Years
1995-2006: The Matlab Years (with C for cmex)
2003-2006: The Disenchantment Years
2006-present: The Python Year(s)
Flexible, powerful language
Multiple programming paradigms
Easy, clean syntax
Large community of support
“Batteries included”
Free as in “free beer”
Free as in “free speech”
Minimum
python | - | the base language |
numpy | - | array class, numerical routines |
scipy | - | higher level scientific routines (depends on numpy) |
matplotlib | - | visualization |
ipython | - | a more flexible python shell |
Packages for a Useful Computational Environment
Minimum
python | - | the base language |
numpy | - | array class, numerical routines |
scipy | - | higher level scientific routines (depends on numpy) |
matplotlib | - | visualization |
ipython | - | a more flexible python shell |
Packages for a Useful Computational Environment
Minimum
python | - | the base language |
numpy | - | array class, numerical routines |
scipy | - | higher level scientific routines (depends on numpy) |
matplotlib | - | visualization |
ipython | - | a more flexible python shell |
Packages for a Useful Computational Environment
Minimum
python | - | the base language |
numpy | - | array class, numerical routines |
scipy | - | higher level scientific routines (depends on numpy) |
matplotlib | - | visualization |
ipython | - | a more flexible python shell |
Packages for a Useful Computational Environment
Minimum
python | - | the base language |
numpy | - | array class, numerical routines |
scipy | - | higher level scientific routines (depends on numpy) |
matplotlib | - | visualization |
ipython | - | a more flexible python shell |
Packages for a Useful Computational Environment
Useful
pyrex - writing fast compiled extensions
(like cmex, but way better)
wxpython - GUI library pywin32 - Windows COM Interface BeautifulSoup - HTML Parser xlrd, pyXLWriter - Reading/Writing Excel Spread-
sheets
Packages for a Useful Computational Environment
Useful
pyrex - writing fast compiled extensions
(like cmex, but way better)
wxpython - GUI library pywin32 - Windows COM Interface BeautifulSoup - HTML Parser xlrd, pyXLWriter - Reading/Writing Excel Spread-
sheets
Packages for a Useful Computational Environment
Useful
pyrex - writing fast compiled extensions
(like cmex, but way better)
wxpython - GUI library pywin32 - Windows COM Interface BeautifulSoup - HTML Parser xlrd, pyXLWriter - Reading/Writing Excel Spread-
sheets
Packages for a Useful Computational Environment
Useful
pyrex - writing fast compiled extensions
(like cmex, but way better)
wxpython - GUI library pywin32 - Windows COM Interface BeautifulSoup - HTML Parser xlrd, pyXLWriter - Reading/Writing Excel Spread-
sheets
Packages for a Useful Computational Environment
Useful
pyrex - writing fast compiled extensions
(like cmex, but way better)
wxpython - GUI library pywin32 - Windows COM Interface BeautifulSoup - HTML Parser xlrd, pyXLWriter - Reading/Writing Excel Spread-
sheets
Packages for a Useful Computational EnvironmentOptimization and Least Squares
. . . and everything is an object: lists, arrays, functions, integers, etc. . .
. . . so all parameters are pass by reference. We’re all adults here.
numpy.delete numpy.diagflat numpy.digitize | numpy.dstack | |
numpy.deprecate numpy.diagonal | numpy.double | numpy.dtype |
numpy.divide ‘?’ notation for help In [4]? Type: function Base Class: String Form: Namespace: Interactive | numpy.dsplit | |
File: Definition: (v, k=0) |
returns a copy of the the k-th diagonal if v is a 2-d array or returns a 2-d array with v as the k-th diagonal if v is a 1-d array.
Docstring:
Optimization and Least Squares
Optimization and Least Squares
Date,Open,High,Low,Close,Volume,Adj Close
2007-04-25,2533.54,2551.39,2523.84,2547.89,2644120000,2547.89
2007-04-24,2528.39,2529.48,2509.26,2524.54,2220610000,2524.54
2007-04-23,2525.77,2531.40,2518.47,2523.67,1928530000,2523.67
Optimization and Least Squares
Rosenbrock Function of N Variables
N−1
f
i=1
Minimum at x0 = x1 = = 1
Perform the Optimization
Optimization and Least Squares
Rosenbrock Function of N Variables
N−1
f
i=1
Minimum at x0 = x1 = = 1
Perform the Optimization
Optimization and Least Squares
Rosenbrock Function of N Variables
N−1
f
i=1
Minimum at x0 = x1 = = 1
Perform the Optimization
Optimization and Least Squares
Notable Differences in Favor of Matlab
(Currently 2355 packages as of 5/08/2007) (Currently 2355 packages as of 5/08/2007)Questions?