User Tools

Site Tools


rpl:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
rpl:start [2019/02/13 04:26]
pier4r
rpl:start [2019/02/17 12:33] (current)
pier4r Editing functions related to random integers and sequences
Line 727: Line 727:
   \<<   \<<
     RAND * CEIL     RAND * CEIL
 +  \>>
 +  ​
 +  randIntRangeHelp
 +" url: '​-',​
 +  tags: [ '​random number',​ '​statistics'​ ],
 +  description:​
 +    returns a random integer in the specified value
 +  ​
 +  Input:
 +  L2: min value
 +  L1: max value
 +  output: an integer (as real) between min and max value included
 +"
 +  randIntRange
 +  \<<
 +    \->
 +    lvMin
 +    lvMax
 +    \<<
 +      lvMax lvMin - @the distance max-min
 +      1 + @a value that we need to offset CEIL later
 +      RAND * CEIL
 +      1 -
 +      @due to ceil, if the size of the range is, say, 4 large,
 +      @one would expect values in (0,1,2,3,4) but with ceil 0 is never happening.
 +      @Thanks to a larger range we have (0,​1,​2,​3,​4,​5) where 0 is never happening.
 +      @Thus we have (1,2,3,4,5)
 +      @Then we need to shift of one value on the left, obtaining (0,1,2,3,4) as wished
 +      lvMin
 +      +
 +    \>>
   \>>   \>>
   ​   ​
Line 743: Line 774:
     2 RAND * FLOOR     2 RAND * FLOOR
   \>>   \>>
-  ​ 
-  @url: '​groups.google.com/​d/​msg/​comp.sys.hp48/​mK0ywSIJ5Ho/​5lP9xux0CAAJ',​ 
-  @tags: [ '​random integer list' ], 
-  @description:​ 
-  @  random integer list without duplicates 
-  ​ 
-  @input 
-  @L2: max positive integer (from 1) 
-  @L1: number of integers to get 
-  @example: 
-  @L2: 10 (we want the integers between 1 and 10) 
-  @L1: 5 (we want 5 integers) 
-  randIntListNoDUP 
-  \<< \-> t n 
-    \<< 1 t 
-      FOR x x DUP RAND * CEIL ROLLD 
-      NEXT t n - DROPN n \->LIST 
-    \>> 
-  \>> ​ 
   ​   ​
   ​   ​
Line 1094: Line 1106:
     \>>     \>>
   \>>   \>>
 +  ​
 +  @url: '​groups.google.com/​d/​msg/​comp.sys.hp48/​mK0ywSIJ5Ho/​5lP9xux0CAAJ',​
 +  @tags: [ '​random integer list' ],
 +  @description:​
 +  @  random integer list without duplicates
 +  ​
 +  @input
 +  @L2: max positive integer (from 1)
 +  @L1: number of integers to get
 +  @example:
 +  @L2: 10 (we want the integers between 1 and 10)
 +  @L1: 5 (we want 5 integers)
 +  randIntListNoDUP
 +  \<< \-> t n
 +    \<< 1 t
 +      FOR x x DUP RAND * CEIL ROLLD
 +      NEXT t n - DROPN n \->LIST
 +    \>>
 +  \>> ​
   ​   ​
   listRandSeqHelp   listRandSeqHelp
rpl/start.txt · Last modified: 2019/02/17 12:33 by pier4r