TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Python+Scipy+Matplotlib vs Matlab?

73 pointsby schtogover 16 years ago
I'm learning datamining, machine learning, image processing etc by myself now but will start uni next year probably doing the same.<p>I tried Octave briefly and wasn't that impressed. Ok some neat functionality and easy matrix manipulation but pretty ugly and language isn't as nice as Python. Not sure about interoperability with other tools.<p>I already knew Python so I naturally tried numpy+scipy+matplotlib and was literally blown away. So easy to use, really nice plotting capabilities and it is extremely convenient using a real and interactive programming language, especially when that language is Python. Being able to do everything with one tool is awesome.<p>I haven't tried Matlab yet because it costs money. Big minus right there obv especially since it is not exactly cheap. It is also proprietary which is a another problem. From what I have gathered it is an awesome tool though and there are huge amounts of Matlab-code out there.<p>Have any of you tried both? Which do you prefer and why? Do you think Scipy can take over? Python seem to be used everywhere in science; signal processing, chemistry, bioinformatics, NASA, Google etc.<p>I have found a library for pretty much everything for Scipy though. I mean having 10 different FFT-libs isn't exactly much of a plus, one great one is enough. So does Matlab beat Scipy on that point or not? And is Matlab much better than Octave? Different feel? Does Matlab allow easy interaction with databases and other tools?

21 comments

dhbradshawover 16 years ago
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.).<p>sage is built as an extension to Python with both a terminal interface (extended version of ipython) and a web-based interface. It builds on Scipy and many other tools.<p>Anyway, it's a strong enough system that I've used it to replace both Mathematica and Matlab in my daily activities. It's FFT is similar in speed to that of Matlab (both based on the same open source software). Check it out.
评论 #363844 未加载
gaiusover 16 years ago
Interesting you should say this, as this is exactly what I've been doing this week as well.<p>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 <i>engineers</i>, 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 the first GUI programming I did that wasn't just for myself.<p>What you're paying for with MATLAB is access to the Mathworks Toolboxes. If you need them then it's absolutely worth every penny. If you don't, Octave will do. You also get prettier graphics with MATLAB than gnuplot can do. Matplotlib is good, but it's nowhere near MATLAB, which does a heck of a lot more than plotting 2D graphs.<p>I think Python will get an increasing market share here because it's free and easy to use and lets you do things that are clunky in MATLAB like parsing log files (in the past I have used C or Perl to munge things into a format MATLAB will like tho' it <i>is</i> possible in m-files). I don't think MATLAB is in any danger tho', it does too much too well and has enormous mindshare and legacy (no-one doing civil or mechanical or aeronautical engineering cares what Google uses to show people ads - SRSLY). Think about how people happily pay for Photoshop when there's GIMP. DSP is another big MATLAB market, but (AFAIK) biologists aren't doing the matrix-heavy computations that it's best suited for.<p>You can get a cheap version of MATLAB when you're a student (or know a student) it used to have a limited matrix size (256*256 IIRC) but I think now it doesn't. That was sufficient for the Mech Eng stuff I was doing, but not in my 3rd year when I got into image recognition. It's really nice, definitely worth trying, your university probably already has it.
评论 #363854 未加载
telover 16 years ago
Matlab is, to the programmer with experience in almost any other language, a tremendous horror. The language is almost as cobbled together and inconsistent as PHP with the added bonus of being worked on almost exclusively by engineers instead of people who actually want to write programs (this coming from an engineering student here).<p>That being said, if you have the mathematical chops to rearrange your problem into something solvable via matrix transformations, you can probably write it quickly and elegantly in Matlab without worrying too greatly about execution speed. Better, the built in toolboxes have already solved huge (engineering) problem spaces. Code already written is better than code potentially written...<p>Unless you want a solution that is repeatable or more general than Matlab affords. At that point you'd be better off doing the math by hand. I feel that the Python <i>et al</i> and C solutions fit into this niche. Prototype the math in Matlab, implement in a language that doesn't suck.
评论 #363322 未加载
SwellJoeover 16 years ago
I worked for Enthought (the people behind SciPy, and now NumPy, as Oliphant works for Enthought, as well) for several years when I lived in Austin. Nearly all of the guys that work on SciPy and Matplotlib came from using Matlab in some capacity or another. I've never worked with Matlab, but from the examples I've seen, I much prefer the Python version of things to the Matlab version.<p>I'll also mention that SciPy is in use at some of the biggest companies in the world, and because of its stronger programming language base, it can be used for much larger problem sets than Matlab. Massive fluid dynamics computing projects, requiring clusters of machines, for example, is feasible (and being done) with SciPy. Likewise for geological data analysis. I don't know anything about parallelizing Matlab, but I'm guessing the possibilities are much greater with Python.<p>And, of course, Python skills are probably more transferable to other work.<p>I don't see how you could lose by trying SciPy. It's free, has a great community of incredibly smart people (it's the community with the highest ratio of PhDs to others that I've ever been a part of), and is fun to play with.
apgwozover 16 years ago
If you're working for personal gain, you're probably better off with the Python+ solution because it's a) cheaper, and b) translates into knowledge that can be harnessed in other applications you write in Python. You're probably unlikely to write a real application in Matlab.<p>If you're going to be doing work at a university, you may find reluctance from the persons you are working with as I did a few years back. The argument you'll likely get is that when you pay for Matlab, you pay for the assurance that the implementation of the tools provided is correct and therefore your research is based on a proven foundation.<p>I saw the argument, agreed, but disagreed in the logic presented that those contributing to Python+numpy+scipy+matplotlib didn't have a vested interest in those tools also being completely correct. Afterall, I hear NASA is using some of this stuff...
评论 #363549 未加载
jimbokunover 16 years ago
I'm going to say the unthinkable here:<p>In my Information Retrieval class, I got numpy/scipy set up and went about implementing homework assignments with it.<p>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.<p>I talked to a classmate who was using Java, and not having any speed problems at all. The night before it was due, I rewrote the whole thing in Java and got it to finish running (I handed in a day late, but at least I had something to hand in.)<p>I'm sure there are tricks to make things faster in Python. (For example, I later figured out a method I was calling was running all Python code, and if I had called a different method, it would have dropped directly into the fast C code.) But with Java, I didn't have to think about performance. It was just fast.<p>Java almost certainly has a library for anything you might possibly want to do. "But," I hear you say, "that means I have to write my program in...Java! <i>shudder</i>"<p>And I empathize with you. Which is why now I'm doing a lot of experimenting with Clojure. Fast as Java, because it compiles to the JVM (as long as you follow as few guidelines.) Access to any Java library with no extra effort on your part. (One of my favorite moments on one of Rich Hickey's Clojure video is where he shows a macro that makes Java calls requiring FEWER parentheses than Java. He was pretty excited about that.) I found a Java open source matrix library that, while not nearly as pretty as Python, got the job done.<p>So, that's my totally radical recommendation. Clojure + whatever Java libraries you need to get your work done.
评论 #363872 未加载
评论 #409478 未加载
jonmc12over 16 years ago
Here is one take on Python vs Matlab: <a href="http://vnoel.wordpress.com/2008/05/03/bye-matlab-hello-python-thanks-sage/" rel="nofollow">http://vnoel.wordpress.com/2008/05/03/bye-matlab-hello-pytho...</a><p>Also, check out Enthought's distribution: <a href="http://www.enthought.com/products/epd.php" rel="nofollow">http://www.enthought.com/products/epd.php</a>
评论 #363210 未加载
wesmover 16 years ago
I've had a lot of luck building scientific / research tools in Python / NumPy with Matplotlib. Integrating Fortran / C / C++ code is extremely easy as well, things like Cython / Pyrex also ease that quite a bit as well.<p>My biggest complaint about Matlab (besides the licensing) is that it's just a horrendously bad programming language (if you can call it a language at all). Any self-respecting hacker deserves better.<p>Matlab you have to buy a toolbox for everything (e.g. SQL database interaction). There is not (for most applications) you could want to do that Matlab can do and Python + NumPy can't.
评论 #363183 未加载
评论 #363133 未加载
miloshhover 16 years ago
If you're affiliated with a university, it's very likely that a Matlab license is already available to you. I do research in graphics, and I find it extremely productive to test ideas in Matlab. you can hardly find a better time-saving procedure than testing an idea in Matlab and knowing in 10 minutes that it doesn't work, instead of spending a week implementing it in C++. Once you find what works, re-implementation in C++ is a breeze.
tlbover 16 years ago
I've used both and I greatly prefer python+scipy+matplotlib. Because it's a real programming language, unlike Matlab's clunky Basic-like thing. So if matplotlib doesn't do what you need, you can extend it or just write something custom in GTK+Cairo. The depth and stability of scipy &#38; matplotlib is very impressive.
mwexlerover 16 years ago
Depending on your bent, you may find R (<a href="http://www.r-project.org/" rel="nofollow">http://www.r-project.org/</a>) with Python (<a href="http://www.omegahat.org/RSPython/" rel="nofollow">http://www.omegahat.org/RSPython/</a>) a very powerful combination. More statistical than some of the others you mention, and sadly constrained by memory unless you play some games, you will probably find that most cutting edge stats code is available for R. Data mining and AI folks also use R, but as you point out, other matrix and functional languages may fit your specific approach.
pskomorochover 16 years ago
Numpy/Scipy syntax is very close to matlab, but python is a lot more powerful. I port matlab code over to python pretty frequently.<p>A toy example is here along links to other comparisons: <a href="http://www.datawrangling.com/python-montage-code-for-displaying-arrays" rel="nofollow">http://www.datawrangling.com/python-montage-code-for-display...</a>
koraybalciover 16 years ago
Most universities have studen license servers for Matlab afaik. And, Matlab is really really, annoyingly powerful. You've got almost anything to try your ideas, implement an academic paper. But, it is slow (execution time).<p>Prototype with Matlab, implement with C++. That's what I usually prefer. I am not a Python expert, just learning it. but I think it will be slower than C, and less powerful than Matlab, from my perspective of working.
评论 #363560 未加载
评论 #363159 未加载
zentuxover 16 years ago
In my opinion,"Python+Scipy+Matplotlib" can replace the "equal" libs in MATLAB. I had the same problem with python when I decided to develop a face detection software by useing Neural Networks ! In that period of time, there were no complete N.N. lib for python. I don't think that there is any comprehensive one too. long story short, if you want to stick to some small libs, that mixture is OK. But if you want to develop your field (like blending NN and DIP) you will fall in trouble .... As a solution, you can mix python and libs like OpenCV for computer vision and image processing . Check pyOpencv too :)
tlbover 16 years ago
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.
lutormover 16 years ago
I don't like the looks of the pylab graphs, I wouldn't put them in a paper. However, there's also PyX (<a href="http://pyx.sourceforge.net/index.html" rel="nofollow">http://pyx.sourceforge.net/index.html</a>) which is a little more verbose in usage but makes very nice "latexy" plots that go well along with a latexed paper. And it can do some really advanced stuff, too, that I wouldn't even know how to begin thinking about doing in pylab.
ytersover 16 years ago
Here is a benchmark comparing R, Octave, Matlab, S-PLUS, and a few other common mathematical programming languages.<p><a href="http://www.sciviews.org/benchmark/index.html" rel="nofollow">http://www.sciviews.org/benchmark/index.html</a><p>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.
huangnankunover 16 years ago
I find that matlab is a great program to try out new ideas and algorithms when you are just starting out. The plotting library is also very easy to use and there are many helpful built in functions for matrix, linear algebra manipulations. However the language itself is a horror to code in, its based on fortran. I still really hate the 1 based array indexing after using it for years.
评论 #363632 未加载
ninjaaover 16 years ago
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.<p>Still, Py handily beats other free alternatives to Matlab
评论 #371010 未加载
评论 #364025 未加载
Predictorover 16 years ago
Tastes vary (as the mix of comments here will attest), but having sampled a variety of development and analysis tools, I have settled on MATLAB as my tool of choice. Part of my reasoning can be found in the Nov-08-2006 posting to my Weblog, "Why MATLAB for Data Mining?":<p><a href="http://matlabdatamining.blogspot.com/2006/11/why-matlab-for-data-mining.html" rel="nofollow">http://matlabdatamining.blogspot.com/2006/11/why-matlab-for-...</a>
评论 #477101 未加载
newt0311over 16 years ago
Well... matplotlib (and scipy to a lesser extent) have atrocious design and documentation from a programming perspective. On the other hand, Matlab is worse in that regard and Python is an excellent general purpose programming language. Unless you plan on using one of the more obscure libraries that come with Matlab, I would advise the python combo.