[OLPC library] MATLAB for OLPC?

Ian Bicking ianb at colorstudy.com
Wed Jan 30 13:18:57 EST 2008


Speaking of the free alternatives (of which I only know a bit -- I don't 
actually do any of this kind of work), I haven't noticed anyone mention 
RPy (http://rpy.sourceforge.net/) which provides some integration 
between R and Python.  It would probably be very helpful for porting R 
to the XO, as you could write Activity wrapper in Python, and/or hook 
into things like the Journal using the bindings.  I don't really know 
what the difference is between RPy and R/SPlus, it's not immediately 
obvious.

Matplotlib (http://matplotlib.sourceforge.net/) implements a lot of 2D 
graphing for Python.  The graphs is creates can be quite nice, and the 
API is pretty simple.

I'm not really sure what the end-user experience is that people are 
looking for.  An interactive prompt to explore data?  A full GUI for 
managing the data?  A tool that can be used by other Activities that 
actually have the data?


Mel Chua wrote:
> On the subject of transcribing MATLAB to numpy, aside from the
> aforementioned smattering of dependencies on MATLAB environmental
> features, I would say the answer to your question is: very hard. Not
> only are the numpy types not a one-to-one mapping with MATLAB types;
> MATLAB syntax is optimized around certain assumptions about matrix
> iteration at a deep level. I don't fully understand the inner
> workings, but my impression is it would require tweaks in the Python
> interpreter and stack to get it running MATLAB computations at a
> reasonable efficiency.

I'm not sure his summary here is true.  You can do efficient operations 
over sets of data in Python (actually due to some small tweaks to the 
language requested by NumPy/Numeric users back around the time of Python 
2.1).  So if you do something like "array * 6", it actually does the 
multiplication of items in the array in C.  They bend Python's "magic 
methods" quite a bit in NumPy, so things like array access, slicing, and 
multiplication all avoid actually iterating over the arrays or matrixes 
in Python.

While I imagine Matlab has a greater number of routines and algorithms 
written in C or other efficient languages, from Python you can access 
similarly efficient algorithms (once they get written).

Actually interpreting another language in Python, or translating a 
language to Python, is probably infeasible.  I've never been a fan of 
attempts to do this that I've seen in the past.  If you actually want 
the Matlab language then you probably need to start with that as a goal, 
as Octave seems to do.  I'm not sure of what the goal of having a 
translation from Matlab would be.  Lots of XO users already know Matlab? 
  That seems unlikely.  There are libraries implemented for Matlab that 
would be really hard to port/reimplement?  Maybe.  You want XO users to 
collaborate with scientists who are using Matlab?  I suppose; except 
it's easy to transfer exact code, but hard to transfer familiarity, so 
while Octave builds on people's Matlab familiarity I'm not sure you can 
confidently transfer actual code from Matlab to Octave.

Given a very specific goal, I am guessing that NumPy plus Matplotlib 
would probably be a good base for building an Activity.  For generic 
goals -- analyzing data in novel ways -- straight Python may be too 
undirected, and writing a directed Activity would probably be a 
significant undertaking.

   Ian



More information about the Devel mailing list