- jwebb's home page
- Posts
- 2019
- 2018
- 2017
- 2016
- 2015
- 2014
- 2013
- November (1)
- October (1)
- September (1)
- July (1)
- June (1)
- April (1)
- March (3)
- February (1)
- January (1)
- 2012
- 2011
- December (2)
- September (3)
- August (5)
- July (6)
- June (6)
- May (1)
- April (5)
- March (5)
- February (2)
- January (2)
- 2010
- December (3)
- October (3)
- September (2)
- August (2)
- June (2)
- May (4)
- April (4)
- March (2)
- February (4)
- January (10)
- 2009
- 2008
- 2007
- 2006
- July (1)
- My blog
- Post new blog entry
- All blogs
HOWTO: Set random number seeds in starsim
seed1 = 123 seed2 = 456 RNDM [seed1] [seed2]
How to select seeds for the random number generator which will (almost certainly) be independent for any two jobs:
SET = "some number which is independent from run to run" TIME = $shell('date +%s') NANO = $shell('date +%N') TIME = [TIME] + 1000000*[SET] RNDM [TIME] [NANO]
Yes, you could just set seed1 = [SET]... but that will typically result in a seed which is a number on the order of 10 to 100 to 1000, depending on how many jobs you set. With this method, [TIME] will take on a value equal to the number of seconds which have elapsed since 1/1/1970, and offset by approximately one day for each set. [NANO] will be the number of nanoseconds in the current second... so the combination of the two seeds will be very unlikely to occur twice on two separate calls.
I will buy a beer for the first person who can calculate the probability of two runs submitted w/in one day of each other with SET on the order of 1 to 10 having seed1 = seed2.
- jwebb's blog
- Login or register to post comments