akcs.dfrancis@tronsbox.UUCP (Dennis Francis Heffernan) (11/13/89)
Having some trouble with random numbers in REXX (Amiga version). It seems that every time I run a script, it generates the SAME random numbers. I've tried reseeding without success. Is there something wrong here, or am I a bonehead?
CMH117@PSUVM.BITNET (Charles Hannum) (11/15/89)
You are a bonehead. The first time you call the random number generator, (RANDOM), you need to give it a "seed" value as the third argument, otherwise you will continue to get the same numbers every time ...
exspes@gdr.bath.ac.uk (P E Smee) (11/16/89)
In article <89318.193843CMH117@PSUVM.BITNET> CMH117@PSUVM.BITNET (Charles Hannum) writes: >You are a bonehead. The first time you call the random number generator, >(RANDOM), you need to give it a "seed" value as the third argument, otherwise >you will continue to get the same numbers every time ... Really? If so, then Arexx has got it backwards. In 'proper' REXX (to quote from the manual) [If you specify a seed in the first call] the numbers are generated mathematically, using the initial seed, so that as far as possible they appear to be random. Running the program again will produce *the same sequence*; using a *different* initial seed will produce a *different* sequence. If you *do not* specify a seed, the first time RANDOM is called, the microsecond field of the time-of-day clock will be used as the seed; and hence your program will give different results each time it is run. (*'s are mine for emphasis). If you think about it, it has to be this way, as otherwise you need a 'metaRandom' function of some sort to provide an initial seed for your RANDOM function if you want non-repeating behaviour. -- Paul Smee | JANET: Smee@uk.ac.bristol Computer Centre | BITNET: Smee%uk.ac.bristol@ukacrl.bitnet University of Bristol | Internet: Smee%uk.ac.bristol@nsfnet-relay.ac.uk (Phone: +44 272 303132) | UUCP: ...!uunet!ukc!gdr.bath.ac.uk!exspes
bdb@becker.UUCP (Bruce Becker) (11/17/89)
In article <89318.193843CMH117@PSUVM.BITNET> CMH117@PSUVM.BITNET (Charles Hannum) writes: |You are a bonehead. The first time you call the random number generator, |(RANDOM), you need to give it a "seed" value as the third argument, otherwise |you will continue to get the same numbers every time ... One of the great things about the net is how sweet people are to each other. At least some useful information was imparted along with the abuse... Grunt, -- .::. Bruce Becker Toronto, Ont. w \@@/ Internet: bdb@becker.UUCP, bruce@gpu.utcs.toronto.edu `/c/-e BitNet: BECKER@HUMBER.BITNET _/ \_ Your Agrarian Distress Card - Don't heave loam without it...
CMH117@PSUVM.BITNET (Charles Hannum) (11/18/89)
In article <1108@becker.UUCP>, bdb@becker.UUCP (Bruce Becker) says: > >In article <89318.193843CMH117@PSUVM.BITNET> CMH117@PSUVM.BITNET (Charles >Hannum) writes: >|You are a bonehead. The first time you call the random number generator, >|(RANDOM), you need to give it a "seed" value as the third argument, otherwise >|you will continue to get the same numbers every time ... > > One of the great things about the net is how sweet > people are to each other. > > At least some useful information was imparted along > with the abuse... What? He asked "or am I a bonehead?" I was just answering his question! -- - Charles Martin Hannum II "Klein bottle for sale ... inquire within." (and PROUD OF IT!!!) "To life immortal!" c9h@psuecl.psu.edu "No noozzzz izzz netzzzsnoozzzzz..." cmh117@psuvm.psu.edu "Mem'ry, all alone in the moonlight ..."
CMH117@PSUVM.BITNET (Charles Hannum) (11/18/89)
In "standard" REXX, you are correct. However, in Arexx you must specify the initial seed value. I had assumed that anyone reading my posting would think to choose a fairly random value (i.e. the time of day) for the seed. -- - Charles Martin Hannum II "Klein bottle for sale ... inquire within." (and PROUD OF IT!!!) "To life immortal!" c9h@psuecl.psu.edu "No noozzzz izzz netzzzsnoozzzzz..." cmh117@psuvm.psu.edu "Mem'ry, all alone in the moonlight ..."
akcs.dfrancis@tronsbox.UUCP (Dennis Francis Heffernan) (11/20/89)
Why thank you, Mr. Hannum. For what it's worth, I DID supply a seed value. Of course, it gave me the same values over and over. I was really hoping that someone would tell me HOW to use the clock or such to generate seed values, as that's something the manual doesn't seem to cover. I had assumed that anyone reading my posting would realize that I had read at least the part of the manual dealing with the random commands... but of course, we all know we shouldn't assume.
kim@uts.amdahl.com (Kim DeVaughn) (11/21/89)
In article <[2567807d:14.4]comp.lang.rexx;1@tronsbox.UUCP>, akcs.dfrancis@tronsbox.UUCP (Dennis Francis Heffernan) writes: > > I was really hoping that someone would tell me HOW to use the clock or > such to generate seed values, as that's something the manual doesn't seem > to cover. The following code fragment should show you how to use "random" to get a non- deterministic initialization. As an aside, it is part of some code I used to get a unique tempfile name in an ARexx clone of "readnews". It was implemented before v1.10 came out, hence the somewhat unusual use of "getspace()", etc. In v1.10 there is a "pragma" that eliminates the need to use "getspace()" in this way, and there's also a direct "d2x()" function in v1.10. /* */ [ ... ] call random(0, 255, time("S")) tmpfile = tempdir || "rnews" || translate((right(c2x(getspace(8)), 6) || c2x(d2c(random(0, 255)))), "abcdef", "ABCDEF") [ ... ] /kim -- UUCP: kim@amdahl.amdahl.com or: {sun,decwrl,hplabs,pyramid,uunet,oliveb,ames}!amdahl!kim DDD: 408-746-8462 USPS: Amdahl Corp. M/S 249, 1250 E. Arques Av, Sunnyvale, CA 94086 BIX: kdevaughn GEnie: K.DEVAUGHN CIS: 76535,25
CMH117@PSUVM.BITNET (Charles Hannum) (11/22/89)
There is no reason to be rude or sarcastic. I simply answered your questions. If that solution didn't work, all you needed to do was supply more information. I think we're being a little too jumpy here. I don't expect to get flamed for trying to help someone. -- - Charles Martin Hannum II "Klein bottle for sale ... inquire within." (That's Charles to you!) "To life immortal!" cmh117@psuvm.{bitnet,psu.edu} "No noozzzz izzz netzzzsnoozzzzz..." c9h@psuecl.{bitnet,psu.edu} "Mem'ry, all alone in the moonlight ..."
akcs.dfrancis@tronsbox.UUCP (Dennis Francis Heffernan) (11/22/89)
Thanks, Kim, and thanks also to Dan Albers, who replied in mail, and I couldn't figure out how to send mail back to him from this ACKS BBS I'm on.