Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Math Forum
»
Discussions
»
Software
»
comp.softsys.matlab
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
starting from certain ceed of random number in different scripts
Replies:
1
Last Post:
Apr 8, 2013 10:10 AM




Re: starting from certain ceed of random number in different scripts
Posted:
Apr 8, 2013 10:10 AM


Ahmed, you are correct in observing that randn('state',200) is no longer recommended. Let me make a couple of comments about your other questions:
1) The second and third lines here > rng('default'); > S = RandStream('mt19937ar','seed',5489); > reset(RandStream.getDefaultStream);
are unnecessary, and in fact the second line has no effect at all on the randn function (because S is never set as the global stream). All you need here is the first line. You should use either the rng function, or the RandStream class, but not both.
2) I can't tell from your description, and you're the only one who can decide for sure, but it may be that you do not need to set seeds at all. If you are running in one MATLAB session, the number you get from running three scripts in a row will be statistically (pseudo)independent.
3) It's true that randn in the default configuration, using the Mersenne Twister behind it, is slower than the using the old configuration from preR2008a.
>> rng(0,'twister'); tic, for i = 1:100000, x = randn(1000,1); end, toc Elapsed time is 1.638594 seconds. >> rng(0,'v5normal'); tic, for i = 1:100000, x = randn(1000,1); end, toc Elapsed time is 0.804072 seconds.
But you get what you pay for. The new configuration is a higher quality random number stream. Only you can say if that should matter to you. However, I will say that it's often the case that generating the random values is not what takes the most time in a simulation. Even just a simple exponentiation demonstrates that:
>> rng(0,'v5normal'); tic, for i = 1:100000, x = exp(randn(1000,1)); end, toc Elapsed time is 2.815825 seconds.
4) If you really want to use the older generator, you can do that, but do it like this:
rng(seed,'v5normal')
Hope this helps.
On 4/8/2013 8:10 AM, ahmed wrote: > Hello Every one ; > i want to describ my work before describing the problem, i am applying a > communication system , transmitter the adding channel the receiver. > i want to start from certain points of random numbers in 3 different > scripts so,i used first this command : randn('state',200); > but then i realized that the previous command is not efficent , so i > used the following commands at the start of transmitter: > rng('default'); > S = RandStream('mt19937ar','seed',5489); > reset(RandStream.getDefaultStream); > and to ensure that there isn't a correlation of random numbers , after > ending the transmitter ,i used the following command before adding > channel (fading and noise) : > rng(10000); > then before starting the receiver i used the following command : ( > rng(50000); ) > the problem is , when apply all this commands that are instead of > randn('state',200); , the performance is less that as i used > randn('state',200); , i feel that the the performance is very poor , can > any one help me ?



