1. ## random number generator

Hi. I was wondering if I can make the pseudo-random rand() function more random?
I'm generating a random number between 0 and 2 for 30 times:

for(int i=1; i<=30; i++)

Also, is there a better way than using the current time as the seed, so the sequences generated are more different from each other?

Thanks

2. Hi. I was wondering if I can make the pseudo-random rand() function more random?
I'm generating a random number between 0 and 2 for 30 times:
You create your own 64 random bit generator by using several calls to rand.

Also, is there a better way than using the current time as the seed, so the sequences generated are more different from each other?
If you could find something more random? Some hardware chips might have a special way to get a random number seed.

3. Google for PRNGs (pseudo-random number generators). Some examples of different types are: linear congruential generator, and the mersenne twister (been a while since I've looked in much depth into this stuff, so its a little slow coming to my mind).

Also, you might want to check into the DIEHARD tests.

And, chapter 7 of Numerical Recipes, available here: http://library.lanl.gov/numerical/bookcpdf.html

4. i had seen some applications which use the mouse movement values as a seed... i guess those will give better random values..

5. Originally Posted by Verbenaca

Also, is there a better way than using the current time as the seed, so the sequences generated are more different from each other?

Thanks
Use a higer resolution timer ... I've run into problems using time(), especially if using a script to run a simulation for example. If the program return really fast, when your script runs the next iteration the seed will often be the same because time() is the same. It's resolution is only 1 second so often 2 or 3 iterations may complete in under a second giving you the same seed.