v****c 发帖数: 32 | 1 Random number generator repeats itself
after exactly 2^24 calls, why?
Is there a way to change it?
Thanks in advance for your input. |
I**********s 发帖数: 441 | 2 It's a pseudo-random number generator with a period.
Check a book on algorithm you'll find out.
To change it maybe you need to see the source code. |
i***h 发帖数: 12655 | 3 如果在每个rand之前重新 srand(time())
可以么? |
t****t 发帖数: 6806 | 4 then rand() is indeed a function of time(), which could be random, or could
be totally not random.
(pseudo) random generator is not a trivial topic. the quality of PRNG varies
a LOT. if your program need to use a lot of PRN (e.g. more than 2^16),
usually you have to pick a reasonable generator, instead of blindly using
the rand() comes with libc.
【在 i***h 的大作中提到】 : 如果在每个rand之前重新 srand(time()) : 可以么?
|
z*****a 发帖数: 3809 | 5 Just use a different random number generator, such as
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
【在 v****c 的大作中提到】 : Random number generator repeats itself : after exactly 2^24 calls, why? : Is there a way to change it? : Thanks in advance for your input.
|