From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,47a3564e17a59a63 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-08 02:49:47 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: brianc@billybob.demon.co.uk (Brian A Crawford) Newsgroups: comp.lang.ada Subject: Re: Pseudo Random coding problem Date: Wed, 08 Jan 2003 10:57:54 GMT Message-ID: <3e1c00e7.634181@news.demon.co.uk> References: <3e1b633f.3280604@news.demon.co.uk> <%xLS9.675327$NH2.47318@sccrnsc01> NNTP-Posting-Host: billybob.demon.co.uk X-Trace: news.demon.co.uk 1042022986 13952 194.222.76.2 (8 Jan 2003 10:49:46 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Wed, 8 Jan 2003 10:49:46 +0000 (UTC) X-Newsreader: Forte Free Agent 1.11/32.235 Xref: archiver1.google.com comp.lang.ada:32736 Date: 2003-01-08T10:57:54+00:00 List-Id: My intention was to produce one stream of pseudo random numbers continuously one at a time (until say 10 billion trials) for a simulation; look at that number produced; if it was a 20 then do one action, if it was a 5 or a 10 do another, if it was a 2, 4, 6, 8 do another. This is simplified somewhat. I did it in the range of 1 to 50 and 15 trials just for debugging and checking code. The random range will be 1.. 1Million. The number 20, 2, 5 etc aren't important; it was an easy way of getting a probability of events happening. E.g #2,4,6,8 coming up in 1 million numbers is 250K to 1 etc. According to the replies so far I seem to be producing two streams. How do I produce and check one only. Many Thanks Brian On Wed, 08 Jan 2003 01:55:07 GMT, tmoran@acm.org wrote: >> sometimes sees the value 20 and on other occasions doesn't. > >You are generating 30 random integer from 1 .. 50 (15 from the >"Ada.Integer_Text_IO.Put" and another 15 from the >"if Random_50.Random(Gen => G) = 20 then"). The probability that >none of those is a 20 is (49/50)**30 = 0.55 If the 20 should come >up on the "Ada.Integer_Text_IO.Put" you will see it printed >out. Since those are half of the 30 calls, you ought to see "20" >printed about 0.27 of the time. If the 20 comes up on the >"if" statement instead, you won't see a 20 at all, but will instead >see "Random Number is equal to Twenty". That also should happen >on about 27% of the runs. Running your program 100 times, a quarter >second apart (to let the random generator start differently), I >see 26 of the runs output "Random Number is equal to Twenty" at >least once. Sounds just about right.