tags:

views:

142

answers:

2

I'm writing a program in .NET that will need to utilize the statistical and data analysis functions of R or MATLAB. I have used R but am now contemplating moving to MATLAB since it has a .Net compiler while R can only interface via COM objects. Can anyone recommend going either way? I know MATLAB is infinitely more expensive than R (since R is free) but I'm thinking that may translate to an easier development cycle?

+2  A: 

You've described three approaches: use .NET Builder for Matlab, use Matlab as a COM object, and use R as a COM object. The costs are different for each.

The Matlab .NET Builder lets you create .NET objects, which you can then call directly from .NET. One advantage of this is you can deploy those objects onto machines that don't have Matlab installed by installing the freely redistributable Mathworks MCR on the targets. This will cost you one Matlab license plus the cost of the Matlab .NET Builder. In the comments, Sharpie quotes a total cost of ~$12.8K for this approach, and Richie Cotton quotes ~200 MB for the MCR.

Another approach is to call Matlab as a COM object from your .NET code. There's some documentation for this approach here. This is cheaper for one machine since you don't have to buy .NET builder. But if you want to deploy onto many targets, you'll have to buy Matlab (plus applicable toolboxes) for each, at a cost of ~$2.8K/machine.

I've never used R, but it looks like the latter approach, of calling R as a COM object, is documented here. And of course you can simply deploy R to all your target machines.

I'd guess the last two approaches are equally difficulteasy, so if the routines you need are available in either language, free is a very good price.

mtrw
Pretty good comparison. Last time I checked, the Matlab option would cost you ~2k plus an additional 10k for the compiler and then $800 for each statistics toolbox. Your applications would need to be deployed along with a copy of the Matlab Compiled Runtime (MCR) library. With the R route, you would have to deploy R along with the application, which is probably a little bigger and harder to repackage than the MCR. But it is free. Plus, personal highly biased opinion: R wipes the floor with the Matlab statistics toolbox.
Sharpie
Oh, one thing- it looks like calling Matlab as an ActiveX server could possibly require a copy of Matlab to be installed on each machine the application is deployed to- that would be ~$2800 a pop.
Sharpie
@Sharpie: Applications created with the Matlab compiler just need the MCR (essentially Matlab without the frontend), rather than a complete Matlab licence. You can distribute the MCR freely with your app. It does add ~200Mb to the size of your program though.
Richie Cotton
Right. Just to be clear my last comment was concerning the responder's description of running Matlab as a server and communicating with it via a COM interface. In this case I think you would need at least one, and possibly more than one copy of Matlab depending on how the app was deployed. Thanks for the size info on the MCR-- I thought it was a lot smaller than that!
Sharpie
@Sharpie, @Richie - thanks for the added info. I added it into the answer.
mtrw
Right on! A couple of points in the interest of being complete: 1) The Matlab commercial price is 2K for the base package and average $800 dollars for each toolbox. So if you needed stats AND say, neural networks, that would be $1,600 as those are two separate toolboxes- 2.8K is a minimum estimate based on just one additional toolbox. 2) The COM approach looks like it uses Matlab as a server- so it could be cost/network instead of cost/machine depending on the deployment strategy.
Sharpie
+2  A: 

Which way to go depends upon the stats routines you want to use. As Sharpie mentioned, the Matlab Stats toolbox isn't anywhere near as complete as R + 2000 packages. (Though there is a fair amount of stats code in the Matlab Central File Exchange.) If you find yourself having to code up low-level stats routines in Matlab, then you've picked the wrong choice.

The Matlab-.NET interface is slick, and a little nicer than R-.NET, so you likely will save a bit of development time with it. In fact, our current workplace set up is R for stand-alone stats analyses, and Matlab for integration with .NET apps.

As for the cost, if your employer is happy to pay for the software, don't worry about it. If you are paying for it yourself, go with R. :)

Richie Cotton