Post Reply 
What are good PRNG for calculators?
11-05-2014, 08:23 PM
Post: #28
RE: What are good PRNG for calculators?
(11-05-2014 05:05 PM)Thomas Klemm Wrote:  
(11-05-2014 11:02 AM)jdimijian Wrote:  Hi Thomas,

I'm so glad to find these 2 figures for the first time on the web ! 1017980433 and 1574352261.
(...)
And you, where and how did you find it ?

Not affiliated with HP but I used the trace produced by the Nonpareil emulator of the HP-15C. IIRC you have to build the project with the correct settings. Then you can enable it via Debug -> ❐ Trace.
The output is huge but there's the assembler instruction lc to load a constant. Here's the part where 1574352261 is loaded:
Code:
 06120: 0120 lc 1                                  
cycle  2122  P=b q=4 carry=0  stat=.........9....  
 a=00000000000000 b=02592332694000 c=f1000000000000
 06121: 0520 lc 5                                  
cycle  2123  P=a q=4 carry=0  stat=.........9....  
 a=00000000000000 b=02592332694000 c=f1500000000000
 06122: 0720 lc 7                                  
cycle  2124  P=9 q=4 carry=0  stat=.........9....  
 a=00000000000000 b=02592332694000 c=f1570000000000
 06123: 0420 lc 4                                  
cycle  2125  P=8 q=4 carry=0  stat=.........9....  
 a=00000000000000 b=02592332694000 c=f1574000000000
 06124: 0320 lc 3                                  
cycle  2126  P=7 q=4 carry=0  stat=.........9....  
 a=00000000000000 b=02592332694000 c=f1574300000000
 06125: 0520 lc 5                                  
cycle  2127  P=6 q=4 carry=0  stat=.........9....  
 a=00000000000000 b=02592332694000 c=f1574350000000
 06126: 0220 lc 2                                  
cycle  2128  P=5 q=4 carry=0  stat=.........9....  
 a=00000000000000 b=02592332694000 c=f1574352000000
 06127: 0220 lc 2                                  
cycle  2129  P=4 q=4 carry=0  stat=.........9....  
 a=00000000000000 b=02592332694000 c=f1574352200000
 06130: 0620 lc 6                                  
cycle  2130  P=3 q=4 carry=0  stat=.........9....  
 a=00000000000000 b=02592332694000 c=f1574352260000
 06131: 0120 lc 1                                  
cycle  2131  P=2 q=4 carry=0  stat=.........9....  
 a=00000000000000 b=02592332694000 c=f1574352261000
And then I tried to figure out from the code and the rest of the trace what's going on. Fortunately it turned out not to be very complicated. On the basis of my posts it took me about two hours.

But I was not the first one to find these numbers:
Le Compte est bon - The Total Is Right - Numbers
Code:
*&---------------------------------------------------------------------*
*&      Form  HP11C_RAND                                               *
*&---------------------------------------------------------------------*
FORM hp11c_rand  USING value(p_lim_haute) TYPE i
                 CHANGING p_tirage  TYPE i.
  CONSTANTS : kincr TYPE p LENGTH 10 VALUE '1017980433',
              kbase TYPE p LENGTH 10 VALUE '1574352261',
              k10e10 TYPE p LENGTH 10 VALUE '10000000000'.
  DATA : lseed TYPE i.
  IF next = 0.
    IF ppartie = 0.
      CALL FUNCTION 'GENERAL_GET_RANDOM_INT'
        EXPORTING
          range  = 100000000
        IMPORTING
          random = lseed.
      next = lseed.
    ELSE.
      next = ppartie * 10000.
    ENDIF.
  ENDIF.
  next = ( next * kbase + kincr ) MOD k10e10.
  p_tirage = TRUNC( next / k10e10 * ( p_lim_haute + 1 ) ).
ENDFORM.                    " HP11C_RAND

How did you find these numbers?

Cheers
Thomas

According to the literature the modulo number should be 2^P or 2^P-1 for some P value. My guess is that using 10^Q would produce poor values.

Namir
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: What are good PRNG for calculators? - Namir - 11-05-2014 08:23 PM



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