|
From: | Daniel Molina García |
Subject: | Re: NxN random matrix much cheaper than N^2 random scalars |
Date: | Tue, 18 Nov 2014 10:04:40 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
Hi Andreas,:( I though that it was due to a delay on the call, not in the "for" design.Because for loops are slow in octave. It remembered me something what I experienced in fortran: initializing a rng takes a lot of time and if you include the call accidentally inside a loop instead of calling it only once at the begining the program becomes really slow. Just calling> By the way, I found that specifying the 2 dimensions with a vector (as > in the above example) instead of using two parameters is quicker. How have you exactly measured this? $ time octave --silent program.m several times. I don't have a better idea so I couldn't compare. I found that normrnd is not a matlab function. I suppose the more similar is 'random' with "normal" as parameter, but it seems that "normrnd" is a bit faster. And btw, I found also that "rand" is much faster than "random" with "uniform" as parameter. I'd like to know if "random" has better statistical advantages for a rng, else I would continue using the alternatives. Here are some results I got changing the RNG line in my program: random, "normal": real 0m12.596s normrnd: real 0m23.645s normrnd using [,] : real 0m11.166s !!!! random, "uniform": real 0m11.136s rand: real 0m5.184s |
[Prev in Thread] | Current Thread | [Next in Thread] |