>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  Dictionary

Roll ?  0 0 0 Deal

? y yields a uniform random selection from the population i.y if y is a positive integer, or from the interval of numbers greater than 0 and less than 1 if y is 0. The random seed used begins at 7^5 (16807).
 
  x ? y is a list of x items randomly chosen without repetition from i.y .
 

   ? 6 
0
                
   ? 6 6 6 6 6 6 6 6
0 5 5 4 2 3 2 1

   6 ? 6                      NB. A random permutation
0 1 5 4 3 2

   mean=: +/ % #
   mean ? 1000 # 6
2.459

   ] m=: ? 4 4 $ 9            NB. A random matrix for experimentation
3 8 8 4
2 0 2 7
4 2 3 5
1 1 7 2
          
   -/ . * m                   NB. The determinant of m
_659

   f=: ?@$ % ] - 1:
   3 6 f 9                    NB. Random 3 by 6 table in range zero to one with resolution 9
0.375     1     1  0.5  0.25     0
 0.25 0.875   0.5 0.25 0.375 0.625
0.125 0.125 0.875 0.25 0.875  0.75

   ? 2 1 $ !38x
202466594106002578660243928542852207957556146
 79605116563118621090926071782092415123181713

Several instances of the foreign conjunction are provided to work with random numbers. 9!:(2*n) queries a parameter and 9!:(1+2*n) sets it.

9!:42 y
9!:43 y
RNG Select. Select the random number generator

y  RNG  upper bound  period  period  speed
1  GB_Flip  2^31  _1+2^55  3.60e16  1.0
2  Mersenne Twister  2^32  _1+2^19937  4.32e6001  1.1
3  DX-1597-4d  _1+2^31  _1+(_1+2^31)^1597  1.24e14903  3.0
4  MRG32k3a  _209+2^32  -:*/<:3^~_209 _22853+2^32  3.14e57  7.6
0  sum of above RNGs  11.8

“Speed” is the time for generating one million U(0,1) numbers, with 1.0 being the fastest. ? uses Mersenne Twister as the default RNG. ?. uses GB_Flip as the fixed RNG.

 
9!:44 y
9!:45 y
RNG State. The sequence of random numbers generated by an RNG depends completely on the state. The state is a boxed vector whose interpretation depends on the particular RNG. For example:
   t=: 9!:44 ''  NB. query the RNG state
   5 ?@$ 10000
8590 6147 5158 4729 3522
   2 4 ?@$ 10
2 5 5 5
3 8 0 0
   9!:45 t       NB. set the RNG state

   5 ?@$ 10000
8590 6147 5158 4729 3522
9!:0 y
9!:1 y
Random Seed. Queries and sets the random seed used in random number generation. The initial value is 7^5 . The seed may be a single integer or (for the Mersenne Twister RNG) a list of integers.

128!:4 y RNG Raw. Produces y integers as generated directly by an RNG, used typically for debugging the RNG.



>>  <<  Ndx  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  wd  Help  Dictionary