NB. various random number utilities
NB.
NB. see also ~system\packages\stats\statdist for distributions

NB.*setrl v       set random link
NB.
NB.*rand01 v      generate y. random numbers in interval (0,1)
NB.*rand11 v      generate y. random numbers in interval (_1,1)
NB.*randomize v   sets a random value into random link
NB.
NB.*deal v        deal x. items from y. (no repetition)
NB.*dealx v       deal x. indices from shape y. (no repetition)
NB.
NB.*toss v        pick x. items from y. (with repetition)
NB.*tossx v       pick x. indices from shape y. (with repetition)
NB.
NB. note: y. for deal is data
NB.       y. for dealx is $data
NB.
NB. similarly for toss and tossx
NB.
NB. ---------------------------------------------------------
NB. examples:
NB.
NB.    p=: ;: 'anne dave mary tom'
NB.    words=: ;: inverse
NB.
NB.    words deal p
NB. mary anne dave tom
NB.
NB.    words 3 deal p
NB. tom dave mary
NB.
NB.    words 6 toss p
NB. mary mary dave dave mary tom
NB.
NB.    dealx 2 3
NB. 0 1
NB. 1 1
NB. 0 2
NB. 1 2
NB. 0 0
NB. 1 0
NB.
NB.    3 dealx 3 5 7
NB. 2 4 6
NB. 1 0 6
NB. 2 4 5
NB.
NB.    4 tossx 2 3
NB. 0 2
NB. 1 2
NB. 1 1
NB. 0 2

setrl=: 9!:1

deal=: (# ? #) : (? #) { ]
dealx=: ] #: ?~ : ? & (*/)
toss=: ? @ (# #) { ]
tossx=: ] #: (?@# */)
rand01=: ?@$ 0:
rand11=: <: @: +: @: rand01

NB. =========================================================
randomize=: 3 : 0
([ 9!:1) >:<.0.8*0 60 60 24 31#.0 0 0 0 _1+|.<.}.6!:0 ''
)
