[OpenSTA-devel] When is Random not random?
Brought to you by:
dansut
|
From: Wickersham, P. <Pet...@di...> - 2006-01-06 02:31:31
|
Well, It would appear that the random function used within OpenSTA is not very random. I was having some issues with using RANDOM on a range of 1 - 120000. It didn't appear to me that it was very random since I seemed to get repeating numbers pretty quickly.=20 So, I looked at the source and the code appears to use srand() everytime it calls rand() with the last result from calling rand(). However, this actually ends up producing more collisions more quickly than just calling srand() once.=20 I took the same approach in a sample app and ran a loop for 1000 times generating random numbers between 1 and 30000. Using srand() once produced 974 unique numbers. Using srand() every time with the last result of rand() produce 173 unique numbers. I have not had the opportunity to configure the source to build it and test any changes. In fact, I have the CVS HEAD, so that might be problematic if I read the site correctly. Not to mention that I currently have Visual Studio 2003 -peter=20 |