Guest YetAnotherUsername Posted August 4, 2005 Share Posted August 4, 2005 I don't see any functions in the documentation for setting the random seed, and a few old requests in these forums. How do I set the random seed? I need a sequence of random numbers, but need a seed as well so I can replay the exact same sequence on another machine. I intend passing the seed as a command line parameter. Thanks. Link to comment Share on other sites More sharing options...
Valuater Posted August 5, 2005 Share Posted August 5, 2005 I don't see any functions in the documentation for setting the random seed, and a few old requests in these forums.How do I set the random seed? I need a sequence of random numbers, but need a seed as well so I can replay the exact same sequence on another machine. I intend passing the seed as a command line parameter.Thanks.<{POST_SNAPBACK}>not sure... might work for ya..i was just just playing with the idea 8)#include <GuiConstants.au3> Dim $random_[8], $pass_on; comma delimited For $x = 1 To 6 $random_[$x] = Random(1, 50, 1) Next $pass_on = $random_[1] & "," & $random_[2] & "," & $random_[3] & "," & $random_[4] & "," & $random_[5] & "," & $random_[6] msgbox(0,"random numbers = " & $x -1 & " ","The winning lotto numbers are " & $pass_on & " ")8) Link to comment Share on other sites More sharing options...
/dev/null Posted August 5, 2005 Share Posted August 5, 2005 I don't see any functions in the documentation for setting the random seed, and a few old requests in these forums.How do I set the random seed? I need a sequence of random numbers, but need aYou can't, as the seed is set internally with the current time (according to source 3.1.0). CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
hgeras Posted August 5, 2005 Share Posted August 5, 2005 I'm not sure exactly what a random seed is....Maybe what I'll say sound stupid. If I got this right ,you want fixed patterns of random numbers but in any computer ran.... If that is right,then the only thing you could do to ensure this is to make some txt files with let's say 4000 random numbers each (if im not wrong it will be around 8KB including @CR) and fileinstall() them in your script... Now instead of calling Random() you will read from the file for random numbers but always in the same pattern.... If I got this right ,appraise me.Otherwise ignore me.... Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
jdickens Posted August 5, 2005 Share Posted August 5, 2005 That works. Or just put an algorithm that makes the random numbers in your script and pass the seed, so to speak. Calculate pi for example. J If I am too verbose, just say so. You don't need to run on and on. Link to comment Share on other sites More sharing options...
Ster Posted August 5, 2005 Share Posted August 5, 2005 i was curious about a rand_seed also. i'm disappointed there is no seed generator. in anycase, for those who didnt know, a random seed is usually based on the current timestamp. also the reason you want a random seed generator is so that you DO NOT have a reproducable random number pattern. Link to comment Share on other sites More sharing options...
hgeras Posted August 5, 2005 Share Posted August 5, 2005 I need a sequence of random numbers, but need a seed as well so I can replay the exact same sequence on another machineThat's what i saw and brought up the idea... Any way now i got it better... in a few words you need a random seed to either not have a reproducable pattern or have one at will,right? Correct me if i'm wrong... Useful information about COM/Objects referenceMy Scripts:PapDefragNvidia Temperature Logger V3.0 with graph analyzerAutoiIt Update Checker And Downloader V1.0ArrayPush UDF Link to comment Share on other sites More sharing options...
jdickens Posted August 11, 2005 Share Posted August 11, 2005 Usually you want a truly random value when the application is deployed, but frequently you want reproducible random numbers during development, for proper debugging. J If I am too verbose, just say so. You don't need to run on and on. Link to comment Share on other sites More sharing options...
Jef Posted November 8, 2006 Share Posted November 8, 2006 I've also searched for a method to seed the random() function. Unfortunately AutoIt does not provide a way to seed the generator. And that's a real pitty, because random() uses the best random number generator currently available (the Mersenne Twister). A solution is the program your own Random Number Generator. For people wanting to know more about random number generators, I recommend reading an article I've written for "Basically Speaking" (I think it was in 1997 or 98). The generator I propose is the L'Equyer LCG3 generator. It's one of the best around (read my article what is meant with "the best"), and is suitable even for high-demanding scientific work. And yes, it can be seeded. Here is the AutoIt code: $seed1 = 1234 $seed2 = 2345 $seed3 = 3456 For $i = 1 To 5 $RN = Rand($seed1, $seed2, $Seed3) MsgBox(0, "Rand", "Random number "&$i&"= " &$RN) Next Exit Func Rand(ByRef $seed1, ByRef $seed2, ByRef $seed3) ; Composite Pseudo Random Number Generator ; Source: Pierre L'Ecuyer, Communications of the ACM, 31, 6, June 88 ; An excellent Pseudo RNG with an extremely long period ( >8*10^12). ; ; Returns: single precision uniformly distributed random number ; from range 0.0 ..... 1.0 ; Input: Seed1% Seed value generator 1. Value: 1..32362 (inclusive) ; Seed2% Seed value generator 2. Value: 1..31726 (inclusive) ; Seed3% Seed value generator 3. Value: 1..31656 (inclusive) Local $itemp, $icombined ;*** First algorithm $itemp = Int($seed1/206) $seed1 = 157 * ($seed1 - $itemp*206) - $itemp*21 If $seed1 < 0 Then $seed1 = $seed1 + 32363 ;*** Second algorithm $itemp = Int($seed2/217) $seed2 = 146 * ($seed2 - $itemp*217) - $itemp*45 If $seed2 < 0 Then $seed2 = $seed2 + 31727 ;*** Third algorithm $itemp = Int($seed3/222) $seed3 = 142 * ($seed3 - $itemp*222) - $itemp*133 If $seed3 <0 Then $seed3 = $seed3 + 31657 ;*** Combine the algorithms $icombined = $seed1 - $seed2 If $icombined > 706 Then $icombined = $icombined - 32362 $icombined = $icombined + $seed3 If $icombined < 1 Then $icombined = $icombined + 32362 ;*** Scale to (0.0 , 1.0] Return $icombined * 3.0899E-5 EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now