4 ms·
The title is a bit misleading; it compares the three for one single task only. It's useful as an indication of how a few particular things might be done in Mma,
by gjm11 17y ago
The title is a bit misleading; it compares the three for one single task only. It's useful as an indication of how a few particular things might be done in Mma, MATLAB and Python, but here are a few reasons to be very cautious about (e.g.) looking at the amount of code involved in each case and leaping to conclusions.
1. It's just a single problem.
2. It happens to be (by accident or design) one that plays right to MATLAB's strengths (matrix manipulation and plotting). Numeric Python and Pylab are aiming at pretty much the same domains. Mathematica, less so.
3. The MATLAB code reads the input data from a MATLAB .mat file (which only MATLAB knows how to read and write). The Mma and Python code gets it from a text file. Curiously, the MATLAB code for reading the data is much shorter than the Mma and Python code for the "same" job.
4. The code is less than perfectly idiomatic. For instance, the Mma code for counting null data occupies 11 lines when it could be one line (and that not terribly long or terribly obscure): numbers = BinCounts[Map[Count[#,Null]&,matrix],{0,genes}] .
5. The MATLAB and Python plotting code just accepts the default options for the plots. The Mma plotting code is full of option-setting. Presumably the author really likes the MATLAB defaults and can't stand the Mma defaults. At least one instance of this option-setting (the repeated DisplayFunction -> Identity) is simply explicitly setting the Mma default.
(About half the difference between the Mma column and the others is accounted for by this gratuitous option-setting.)
[NOTE: edited to insert the word "half", which I accidentally omitted.]
The author says "using the wrong tool can cause undue work". That's true, and to some extent his comparison demonstrates this. But it also demonstrates the almost equally obvious principles: "using a tool you don't know how to use well can cause undue work", and "doing unnecessary work just for the sake of making your code longer can cause undue work".
(For the avoidance of doubt: I agree that Mathematica is a poor choice of tool for this job. I think the author of the page could, if he'd bothered, have done a comparison that demonstrates that honestly rather than giving a false impression. He could even have tried them on a variety of tasks, some of which weren't optimized for MATLAB and Python+Numeric+Pylab. But perhaps that would have been "undue work".)
- diN0bot 17y agoi'd love to see pictures of the final output, too, in addition to performance results.
- jacquesm 17y agoThat's a pretty solid argument, I'd hate to play chess against you :) Posts like these should be attached to the original article.
- stcredzero 17y ago3. The MATLAB code reads the input data from a MATLAB .mat file (which only MATLAB knows how to read and write). The Mma and Python code gets it from a text file. But which are the "native" formats for each environment?
- gjm11 17y agoA Python pickle would be comparable to a MATLAB .mat file. For Mathematica, you'd typically either make a text file containing Mma code (e.g., with the Save function) or write binary data in some proprietary Mma form with DumpSave. I'd guess the latter is faster and makes smaller files, but I've never checked. More realistically, though, in any situation where you're seriously trying to decide between Mma, MATLAB and Python, your data will be coming in in some "neutral" format and you'll need to parse it. So the Mma and Python code is much more realistic than the MATLAB code. (But perhaps when the author actually needed to do this, it happened that the previous step had been done in MATLAB. That would explain taking input as a .mat file.)