Post Reply 
147 and 997 Random Generator Algorithm
12-10-2020, 08:50 PM (This post was last modified: 12-12-2020 09:47 PM by Nihotte(lma).)
Post: #2
RE: 147 and 997 Random Generator Algorithm
Hi Gamo !

Thanks for your question in this thread
I have found it interesting !

I asked me how to answer to it and I thought of a method
So !

In first time, I decided to experiment a distribution of 1000 items between 100 numbers : from 0 to 99.
In perfect world, I can expect a fair distribution of 10 items by number (because 100 x 10 = 1000).
I can consider a couple of data as the number (0..99) and its number of draws obtained all along the distribution
And, if I manage to position and accumulate each pair on a line, I should get a correlation of 1 for a slope of 10.

I needed 4 steps to do this :

1) make a distribution of 1000 generations between the 100 numbers
2) see the result of the distribution
3) transfer the results to a statistical structure
4) collect the calculation of the correlation coefficient of the line and calculate the value of its slope. And I would also like to recover the standard deviation of the data.

Well. I said to me : it's a job for my HP35s, it can do this !
It has a huge memory, easy to adress from 0 to 99.
It's not really slow
It has on-board (built-in) statistical functions

Then, I made 3 little programs, one for each step 1 to 3.
(I will make the step 4 from the keyboard of the calculator)

Code:

001 LBL H
    RCL M
    STO I
    0
005 STO (I)     // puts 0 in registers 99..1
    DSE I
    GTO H005
    STO (I)     // puts 0 in register 0
    RCL M       // M is constant for the number of values to join from 0 to M-1
    STO I
    STO (I)     // stores a value in register 100 (to reserve the array from 0 to M-1 and M)
    RCL L       // L is constant 1000 loops/items
    STO I       // I is the loops counter
    PI
    FP
    STO O       // FRAC(PI) in O
017 RCL O       // RAN#
    RCL S       // S is constant 147, 997, ... you need to test
    x
    FP
    STO O       // stores the next seed for random
    RCL M
    x
    IP          // gives a number from 0 to M-1
    STO J
    1
    STO + (J)   // adds 1 to the winning location
    DSE I
    GTO H017
    RCL I
    RCL S
    RTN

Usage of LBL H to obtain the initial distribution and try to test 147 :
147 STO S (or 997 STO S)
100 STO M
1000 STO L
XEQ H


Code:

001 LBL G
    RCL M
    STO I
    1
    STO - I    // stores M-1 in I
006 RCL I
    RCL (I)    // displays number i (from 99 to 1) and its total of draws
    PSE
    DSE I
    GTO G006
    RCL I      
    RCL (I)    // displays number 0 and its total of draws
    RTN

Usage of LBL G to display each result of the distribution from "winners" 99 to 0 :
XEQ G


Code:

001 LBL F
    CL SIGMA   // clears stats registers
    0
    STO T      // stores 0 in the cumulative registers
    STO I
006 RCL (I)
    STO + T    // adds the number of draws of the number i (0..99) in the cumulative register
    RCL T
    FS? 0      // uses cumulative register if flag 0 is not set, 
    x <> y     // otherwise directly uses the number of draws for number i
    1
    RCL + I
    STO I
    SIGMA +    // adds on stats register the couple [i, draws(i-1)] for flag 0 on, otherwise it's [i, Sum of the draws(0..i-1)]
    RCL I
    RCL M
    x > y ?
    GTO F006   // loops if i is less than M (0..99)
    RCL S      // displays basis number generator and stops
    RTN


Usage of LBL F to insert the results of LBL H in the stats registers :
2 axes :
1) to obtain the standard deviations
SF 0
XEQ F
then Sy and oy from the keyboard (blue arrow and +)
2) to evaluate the quality of the linear regression
CF 0
XEQ F
then L.R results with r and m from the keyboard (yellow arrow and -)


Finally, with this set of programs and the proposed sequence of steps :
--> I examine the result of a distribution of 1000 random generations of numbers based on 147 or 997
--> I summary evaluate the quality of this distribution

What do I obtain ?
I think that gives a better correlation for the random numbers obtained on the basis of generator 997 than on the basis of 147
and also it gives less disparity for the total of the draws of each possible number.
That is, the output of numbers over the entire range is more consistent using the generator based on the 997 than on the 147.

Therefore, I thought at first it was better to choose a high number 997 > 147
So I have also tested 23, 653, 1283, 1999, 9929, 9931, 62927, 689459 and 851801
In the reality, there are disparate results !
You should see by yourself. I just give you 3 results on 1000 and 10000 draws each.

Code:

           loops    Sy      oy        r             m
     147  1000     3.54    3.52     0.99987    10.1828
     997  1000     3.19    3.17     0.99988     9.9682
837799  1000     0.00    0.00     1.00000    10.0000
     147 10000    10.78   10.73    0.99996    99.8426
     997 10000    10.21   10.16    0.99995   100.2374
837799 10000     0.00   0.00     1.00000   100.0000


Now, in my turn, I have a question!
Look at the results and see how idyllic the generation obtained on the basis of the number 837799 is ...
Could somebody say how is that?


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-10-2020 08:50 PM



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