Post Reply 
147 and 997 Random Generator Algorithm
12-12-2020, 06:19 PM (This post was last modified: 12-12-2020 09:41 PM by Nihotte(lma).)
Post: #5
RE: 147 and 997 Random Generator Algorithm
(12-08-2020 06:57 AM)Gamo Wrote:  Recently read an old book that teach kid "Math Algorithm" and one of the topic was about the "Random Number Generator."

This book mention using the 147 Algorithm to generate Random Integer.

The steps on how to generate random integer is similar to the 997

Is there any much difference of the random output with these 147 and 997 ??

Thanks

Gamo

Hi Gamo !

Our dear HP11C is not out of the game or simply forgotten.
I suggest you a version of the test module suitable for this machine.

I have made it in 2 modules only

A first one for the generation of the distribution, based on 147 or 997 for example.
Here it is.

Code:

** f  LBL  A
     g Clx
     STO  . 0
     STO  . 1
     STO  . 2
     STO  . 3
     STO  . 4
     STO  . 5
     RCL  7
     STO  0
     f  π
     f  FRAC
     STO  1
  * f  LBL  0
     RCL  1
     RCL  8
     x
     f  FRAC
     STO  1
     RCL  6
     x
     g  INT
     1
     0
     +
     STO  I
     EEX
     STO  +  (i)
     STO  -  0
     RCL  0
     g  x > 0
     GTO  0
     g  RTN

With this usage :

6 STO 6 : for draws from 0 to 5
1200 STO 7 : for 1200 draws (you can begin with 120 to see)
997 STO 8 : to test 997, for example
GSB A

You can read the results of the draws by this sequence :

RCL . 0
RCL . 1
RCL . 2
RCL . 3
RCL . 4
RCL . 5


The 2nd one puts the results in the stats registers of the HP11C
Here it is.


Code:

 ** f  LBL  A
      f  CLEAR  Σ
      STO  9
   * f  LBL  1
      1
      0
      RCL  0
      +
      STO  I
      RCL  (i)
      STO  +  9
      RCL  9
      g  F ?  0
      x <> y
      RCL  0
      EEX
      +
      Σ+
      RCL  0
      RCL  6
      f  x > y
      GTO  1
      g  RTN

This is the usage :

g CF 0
GSB E
- f ŷ, r and x<>y
- f L.R. and x<>y

g SF 0
GSB E
g s and x<>y
g x and x<>y

Just a word on the results !
Curiously, the results I get on the HP11C seem better for the based 147 distribution than this one for 997 !

With 997 for 6 possibilities on 1200 draws, I get these data in registers :
RCL . 0 : 187
RCL . 1 : 184
RCL . 2 : 222
RCL . 3 : 192
RCL . 4 : 223
RCL . 5 : 192

With 147 for 6 possibilities on 1200 draws, I get this data in registers :
RCL . 0 : 210
RCL . 1 : 202
RCL . 2 : 191
RCL . 3 : 195
RCL . 4 : 203
RCL . 5 : 199



One more small precision about the program :
It supports distribution with 10 numbers rather than 6 but you have to add the next steps at the right position :
STO . 6
STO . 7
STO . 8
STO . 9
under
g Clx
STO . 0
STO . 1
STO . 2
STO . 3
STO . 4
STO . 5
and modify the content of the R6 by 10 rather than 6 !

Beware of the possible adaptation for the HP15C : Σ registers are R0..5 on the HP11C


Keep you healthy !
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: 147 and 997 Random Generator Algorithm - Nihotte(lma) - 12-12-2020 06:19 PM



User(s) browsing this thread: 1 Guest(s)