I am doing a research project and need to use Monte Carlo simulation. I want to know, what is better to use: MATLAB or Mathematica? I have used MATLAB before but have heard good things about Mathematica.
views:
789answers:
3If you are running Monte Carlo simulations, you probably need high speed more than any other time. You should write this in C if you need to. Otherwise, MATLAB is perfectly adequate for fast numerical calculations - it uses BLAS and LAPACK to do the heavy lifting.
EDIT: I might add: be very careful about the kind of code you write. Use vector or matrix operations wherever at all possible in MATLAB: even if they look silly, they'll be much faster.
Incredibly trivial example to illustrate:
% Extremely slow:
for i = 1:length(x)
x(i) = 2*x(i);
end
% Extremely fast:
x = 2*x;
If you've the luxury of time you should try both and see which fits your mental model of how to write the simulations better.
If you're passing around and iterating ideas then you may find Mathematica lets you express abstract concepts a little better; if you're writing lots of "straight code" then MATLAB will probably more suitable.
One advantage that Mathematica has over MATLAB is that, unless you buy the Parallel Computing Toolbox (PCT) for the latter, the former has better 'out-of-the-box' tools for parallelising your simulations across multiple cores. I'm not saying that this makes Mathematica better, I think that that decision is down to which of the systems fits your computations better or which fits your thinking better.
I've used both (including PCT with MATLAB) and, as ever with languages, it's horses for courses and Mathematica is better for those jobs which Mathematica is better for, so is MATLAB.