JPhrases/RandomNumbers

From J Wiki
Jump to: navigation, search

10F. Random Numbers

d0=: {.@[ + ?@(] $ -@(-/@[)) Shape y array of random numbers in x
d1=: ?@# x numbers from i.y with replacement
d2=: ? x numbers from i.y without replacement
m3=: 9!:1@<.@(+/ .^&2@(6!:0@])) Randomizing random number seed
m4=: (>:@? % 2147483647&[) @ $ & 2147483646 Random numbers between 0 and 1
m5=: {~ ?~@# Random shuffle of y