[OpenSTA-devel] Re: When is Random not random?
Brought to you by:
dansut
|
From: Daniel S. <da...@Op...> - 2006-01-06 03:27:54
|
Peter Wickersham wrote: > 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. Have you seen/found this bug in the bug DB: http://sourceforge.net/tracker/?group_id=10857&atid=110857&func=detail&aid=415144 It looks like you'll never get anything over 32768 anyway. > It didn't appear to me that it was very random since I seemed to > get repeating numbers pretty quickly. I seem to remember someone talking about this behavior on the Users list or somewhere a long time ago ... can't find it though and there's no bug logged. > 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. Can you give us a source file and line number to save me a little bit of work? I'm only just getting into the inner workings of SCL - the previous SCL internals expert no longer has time to give to this project. > 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. Sounds pretty conculsive - the problem is that changing this behavior means that the REPEATABLE RANDOMs would no longer be ... repeatable, and this obviously isn't a good thing for a potential users existing regression test. We can get around this by making the REPEATABLE RANDOMs keep the old behavior unless a config file is updated somehow, so it isn't such a big deal but it does need baring in mind. > 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 I'm currently having success using a version built with the current Platform SDK and no STLport (contemplating dropping my changes into CVS) but I am using VS6sp6 and have never tried using VS2003 (don't have it). If you want to suggest specific code changes then I can do a test version to make sure this gets sorted. Please feel free to log a bug for this on SF. Cheers /dan -- Daniel Sutcliffe <Da...@Op...> OpenSTA part-time caretaker - http://OpenSTA.org/ |