Live data from Hacker News

Python+Scipy+Matplotlib vs Matlab?

news.ycombinator.com

31–40 of 45 posts

Re: Python+Scipy+Matplotlib vs Matlab?

#31
The other big problem with Matlab is that because it's licensed, you can't just do what you like with it. I've got several servers that I like to be able to crunch numbers on, and that would be not only expensive but incredibly inconvenient to maintain all those licenses of Matlab.

Re: Python+Scipy+Matplotlib vs Matlab?

#32
Here is a benchmark comparing R, Octave, Matlab, S-PLUS, and a few other common mathematical programming languages.

http://www.sciviews.org/benchmark/index.html

Suprisingly, R is one of the best in terms of speed, comparable to Matlab (Matlab is pretty fast if you vectorize your code). Plus, if you like functional programming, the R language is based on Scheme.

Re: Python+Scipy+Matplotlib vs Matlab?

#33
post #23
post #22

Earlier quoted context omitted.

I would consider Matlab to be a DSL grown out of control. If you are working purely with matrix/vector/tensor math, as you say, you can be reasonably comfortable with the language as long as you remember to double-check the docs on nearly every function before you use it just in case there is some strange edge-case it handles awkwardly. Unfortunately, in any real project I've ever done with Matlab you cannot survive…

...some strange edge-case it handles awkwardly. Or stupidly. I don't know if the following should qualify as an edge case generally, but it does in Matlab. The controls lab in the aerospace department at the U of W had a wonderful inverted cart-pendulum device that a grad student was doing some seriously freaky non-linear control research on. We were tasked, as part of a lab, to write a controller in Matlab that woul…

You're misrepresenting the situation a bit. Matlab was not stupid here. The evolutionary algorithm you implemented found a way to satisfy your constraints that you didn't think of. That would have happened regardless of the language you chose.

I'm not arguing that Matlab is beautiful - it's not. I have worked in Matlab for years and years, and know most of its ugliness. But your example highlights your frustration with the task more than any particular weakness of Matlab.

Re: Python+Scipy+Matplotlib vs Matlab?

#34
integer division JUST KILLS Python for scientific computing, it introduces the most disgusting silent errors everywhere. And the visualization functions generally suck compared to the handy plot() of Matlab.

Still, Py handily beats other free alternatives to Matlab

Re: Python+Scipy+Matplotlib vs Matlab?

#35

The sage project (sagemath.org) has explicitly stated that its goal is to become a viable open source alternative to Mathematica, Matlab, and Maple. To a reasonable extent, it has already reached that goal and it is progressing and changing rapidly. And it plays well with other mathematical systems (R, Octave, Mathematica, Matlab, Maple, Maxima, Magma, etc.). sage is built as an extension to Python with both a termin…

Also, NumPy and SciPy are being integrated with Sage.

Re: Python+Scipy+Matplotlib vs Matlab?

#36
post #2

Interesting you should say this, as this is exactly what I've been doing this week as well. If you don't like Octave's language, you won't like MATLAB's, they're almost identical. They were both designed for engineers (I mean engineers , not computer programmers) to explore matrix models interactively, then save their work as scripts - you were never meant to use m-files for general purpose programming. MATLAB was th…

> Think about how people happily pay for Photoshop when there's GIMP.

I don’t think this is a legitimate comparison (i.e. the GIMP isn’t a strictly more powerful but less focused superset of Photoshop’s features; instead it’s a strictly less powerful knock-off with an often unintelligible interface and much less polish). Numpy/Scipy are quite nice, and make creating any tools that need a bit of real programming (i.e. not just matrix math) much much nicer than trying to work with MATLAB. If someone else already built the tools using MATLAB and you don’t need to write any code whatsoever yourself, that’s obviously nicest of all. But that doesn’t sound like what the question is really about.

To the OP: if you already know Python, absolutely use Numpy/Scipy. They are fantastic.

Re: Python+Scipy+Matplotlib vs Matlab?

#37

I'm going to say the unthinkable here: In my Information Retrieval class, I got numpy/scipy set up and went about implementing homework assignments with it. However, no matter how much I tried to push as much as possible down into the matrix libraries implemented in C/C++, the surrounding Python code slowed everything down. I was having trouble getting everything to finish in time to hand in my homework by the deadli…

> However, no matter how much I tried to push as much as possible down into the matrix libraries implemented in C/C++, the surrounding Python code slowed everything down. I was having trouble getting everything to finish in time to hand in my homework by the deadline.

Did you profile your code? What was the slow bit?

Re: Python+Scipy+Matplotlib vs Matlab?

#38

I'm going to say the unthinkable here: In my Information Retrieval class, I got numpy/scipy set up and went about implementing homework assignments with it. However, no matter how much I tried to push as much as possible down into the matrix libraries implemented in C/C++, the surrounding Python code slowed everything down. I was having trouble getting everything to finish in time to hand in my homework by the deadli…

> However, no matter how much I tried to push as much as possible down into the matrix libraries implemented in C/C++, the surrounding Python code slowed everything down. I was having trouble getting everything to finish in time to hand in my homework by the deadline. Did you profile your code? What was the slow bit?

Sorry, it's just been too long now to remember the details. I think it was the EM (expectation maximization) algorithm, though, which is hard to reduce entirely to matrix operations, at least for me it was.

Any good implementations for EM in Python (plus bridged libraries) out there?

Re: Python+Scipy+Matplotlib vs Matlab?

#39
post #33
post #23

Earlier quoted context omitted.

...some strange edge-case it handles awkwardly. Or stupidly. I don't know if the following should qualify as an edge case generally, but it does in Matlab. The controls lab in the aerospace department at the U of W had a wonderful inverted cart-pendulum device that a grad student was doing some seriously freaky non-linear control research on. We were tasked, as part of a lab, to write a controller in Matlab that woul…

You're misrepresenting the situation a bit. Matlab was not stupid here. The evolutionary algorithm you implemented found a way to satisfy your constraints that you didn't think of. That would have happened regardless of the language you chose. I'm not arguing that Matlab is beautiful - it's not. I have worked in Matlab for years and years, and know most of its ugliness. But your example highlights your frustration wi…

No.

The point is that the behavior changes based on whether you are running from the command line or from inside a script, that this is completely arbitrary, and that there was no override possible for this behavior. When run from the command line, simulations for combinations of gains that caused the system to career away did indeed career away, they just continued to do so for the full length of time specified in the function call. That kind of abject flakiness renders the program unsuitable for professional use in that you can't plan for those kind of quirks. I had invested hours by the time I worked out what the bug was, and invested hours more trying to fix it. I finally had to give up, after investing my time and effort, because the platform was fundamentally and fatally incapable of doing what it was asked.

It is completely unacceptable for a package to have such wildly different (and undocumented) behavior for the same exact function call. Matlab was indeed stupid. It was a buggy minefield of stupidity when I was using it.

Finally, it looks like your defense of this awful weakness on the part of Matlab is, ironically, a result of your commitment to the platform rather than a reasoned response to the case outlined.

Re: Python+Scipy+Matplotlib vs Matlab?

#40
post #34

integer division JUST KILLS Python for scientific computing, it introduces the most disgusting silent errors everywhere. And the visualization functions generally suck compared to the handy plot() of Matlab. Still, Py handily beats other free alternatives to Matlab

What do you mean with silent errors? Like float representation?

I find matplotlib to very easy to use and creates beautiful plots but I haven't tried Matlab so can't compare obv.

Post reply on HN