Thursday, March 5, 2015

Matlab and/or the "R" statistics package

Prof. Moshovos asked me about R - the open-source stats and visualization package, and how it compared to Matlab. R is a free download from
I'll break this into several sub-questions:
  • Do R and Matlab address similar needs? Does R 'compete' with Matlab? 
    • in short: yes, to a good extent
  • Could the free R package replace the pricy Matlab for some users?
    • for basic tasks, it might; for specialized toolboxes, optimizations? No.
  • Would Matlab users find any benefit in learning and incorporating R in their software kit?
    • Why not - try it and see...
  • Can R and Matlab be hooked up together?
    • Yes: see RMatlab (linked below)
First, my replies are based on hands-on familiarity with Matlab but only what I've read online about R. Second, my answer to this for ECE users will differ from what you would advise the 'engineer on the street' outside of the University. For someone starting out without existing Matlab licenses, and without access to Mathworks' academic pricing, the chips might fall differently.

Our department holds a large shared pool of licenses for both Matlab, Simulink and a good range of additional toolboxes devoted to various specialized EE/CE subdomains such as power grids, communications, optimization, signal and image processing, RF, etc.

While the R community does produce some (also free) R packages for specialized tasks, I'm prepared to venture (without having searched exhaustively) that they have nothing comparable to the range of detailed, tested and optimized toolboxes offered by Mathworks.

That is (perhaps predictably) the response to this very question offered by Mathworks themselves, here:

We host training events offered by Mathworks once or twice a year. We also have access to Mathworks customer support, which we've found responsive but have not needed to resort to more than a very few times. As a free, open-source package, R does have extensive community 'support' through forums, but no dedicated technical support service. For me this is not a deal-breaker. We're all used to doing our own troubleshooting and online bug research.

Here's an interesting post by a 'forced convert' from Matlab to R (cost driven) who is now quite happy using R alone:

He goes into the issue of performance optimization: Matlab has a large full-time staff dedicated to both code quality and performance. The volunteers developing R may make efforts at both, but I suspect it's asking too much of them to compete with Mathworks on either of these fronts. Matlab has put a lot into leveraging modern multi-core CPUs and the huge floating-point performance of GPUs on better video cards (and dedicated computational GPU boards.)

Does R complement Matlab?

People like R for its strong, flexible set of visualization tools. Matlab also offers lots in the way of visualization, but some might prefer what R has to offer (I can't give an informed opinion of my own on this point.)

Interestingly, enough people have wondered about this that an open-source package "RMatlab" has been released offering interfaces both for calling Matlab from R, and vice versa:

Be aware that R and Matlab have similar but distinct syntax and program structure, so mixing the two may stretch your brain a bit. This PDF goes into some of the nitty-gritty details:

R vs. Matlab syntax and coding rules

No comments:

Post a Comment