To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
In MATLAB 2013a, the function random(...) from the Statistics Toolbox runs 40-50 times slower than the same function in the version 2012b.
Ratios of execution times of the following generators:
(a) random('unif', 0,1) and (b) unifrnd(0,1)
are 110 in MATLAB 2013a and 3.1 in MATLAB 2012b.
That is, the function random(...) is 3x slower than unifrnd(...) in MATLAB 2012b, but the same slowdown is 110x in the new MATLAB 2013a.
Any suggestions how to get the new version to perform as quickly as the previous one? (It would be better to have improved performance in the new version, indeed. ;) )
Below is the script used to measure execution times:
N = 5000;
% (a) tic; sm = 0; for i=1:N sm = sm + random('unif', 0, 1); end toc;
% (b) tic; sm = 0; for i=1:N sm = sm + unifrnd(0, 1); end toc;
Alexander, I will make a note to look into the difference in performance, but a couple of things you might keep in mind (you may already know these, but just in case):
Example 1: Generate values from the uniform distribution on the interval [a, b]. r = a + (b-a).*rand(100,1);
More a comment than an answer:
The random streams objects became more and more complicated since Matlab 5.3. When I e.g. want to get a random array controlled by a seed, I have to look in the documentation each time.
s = RandStream('mt19937ar', 'Seed', now); RandStream.setGlobalStream(s);
I understand, that the new random objects are much more powerful. But simple tasks are looking such ugly yet, that I prefer my own random toolbox - although this is known as a bad programming pattern and too many programs suffered from not relying on heavily tested RNGs.
One problem is, that the symbols "rand", "rng", "random" and "RandStream" must be avoided to keep the backward compatibility. Therefore a cleaner and more convenient new tool or a wrapper needs a not matching name already.
Some measurements with the Mersenne Twister (in R2009a and 2011b) look like the standard implementation is used, while there are some SSE-versions available already, which are much faster.
My conclusion: Matlab's RNG tools ran out of control.