I'm using DevC++ 4.9.9.2 on Windows XP. I want to generate a lot of random numbers all at once. I tried to do this by calling rand() repeatedly, but that doesn't work (I gather that it has something to do with the fact that the time hasn't changed much). I know that in Matlab, you can specify how many random numbers you wish to generate.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> I tried to do this by calling rand() repeatedly, but that doesn't work
> (I gather that it has something to do with the fact that the time
> hasn't changed much)
No, it is because you were doing it wrong! rand() is not dependant in any way on time. It is common to seed the RNG with a value derived from time by passing a time related value to srand(), but you only need to do that once. My guess is that you are doing it before every call to rand() in the loop - which is just dumb - and not random! ;-)
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using DevC++ 4.9.9.2 on Windows XP. I want to generate a lot of random numbers all at once. I tried to do this by calling rand() repeatedly, but that doesn't work (I gather that it has something to do with the fact that the time hasn't changed much). I know that in Matlab, you can specify how many random numbers you wish to generate.
> I tried to do this by calling rand() repeatedly, but that doesn't work
> (I gather that it has something to do with the fact that the time
> hasn't changed much)
No, it is because you were doing it wrong! rand() is not dependant in any way on time. It is common to seed the RNG with a value derived from time by passing a time related value to srand(), but you only need to do that once. My guess is that you are doing it before every call to rand() in the loop - which is just dumb - and not random! ;-)
Clifford
I believe you can do that through GSL, the Gnu Scientific Library. There have been a number of discussions about using GSL in the pages of this forum.
Wayne