🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #1237

ARexx psuedo-random number generator

#1237
From: Eric J. Kennedy
Date: Tue, 12 Sep 1989 03:16
62 lines
2512 bytes
I was having a little trouble with ARexx's random number generator, so I
performed the following small test.  The 1 to 45 range is the range in my
application, so I kept it for the test.  I'm using the time in seconds as the
seed, which strikes me as being the most variable easily obtainable number.

All the program does is calculate 10000 pseudo-random numbers, and do a
histogram of sorts.  

This is using ARexx 1.10.

/****************************************/
/* test ARexx's random number generator */


r=time('S')

do index=1 to 45    /* initialize array */
  hist.index=0
end

do index=1 to 10000 
  r=random(1,45,r)
  hist.r = hist.r + 1
end

do index=1 to 45
  say index hist.index
end
/****************************************/

A typical output is as follows.  (x is the variable, 1 to 45; n is the
number of observations.)


 x   n                x   n                  x   n
 
1  0                 16 182                 31 364  
2  182               17 363                 32 544  
3  0                 18 544                 33 182  
4  181               19 726                 34 544  
5  2                 20 545                 35 181  
6  181               21 181                 36 183  
7  0                 22 364                 37 183  
8  1                 23 0                   38 181  
9  181               24 364                 39 1    
10 0                 25 185                 40 1    
11 1                 26 727                 41 0    
12 181               27 182                 42 0    
13 546               28 727                 43 0    
14 363               29 2                   44 0    
15 544               30 181                 45 0    


Does anybody else notice a slight problem here?  Is there a better method of
using the generator that will avoid this problem, or is this inherent in the
ARexx random number generator?


-- 
Eric Kennedy
ejkst@cis.unix.pitt.edu
Technical Details
Message-ID: <19504@unix.cis.pitt.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!cadre.dsl.pitt.edu!pitt!unix.cis.pitt.edu!ejkst

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!cadre.dsl.pitt.edu!pitt!unix.cis.pitt.edu!ejkst
From: ejkst@unix.cis.pitt.edu (Eric J. Kennedy)
Newsgroups: comp.sys.amiga.tech
Subject: ARexx psuedo-random number generator
Summary: Very psuedo...
Keywords: ARexx Random Number Generator
Message-ID: <19504@unix.cis.pitt.edu>
Date: 12 Sep 89 03:16:18 GMT
Reply-To: ejkst@unix.cis.pitt.edu (Eric J. Kennedy)
Organization: Univ. of Pittsburgh, Comp & Info Services
Lines: 62