Deal: Difference between revisions

Jump to navigation Jump to search
325 bytes added ,  09:34, 4 June 2020
(Created page with "{{Built-in|Deal|?}} is a dyadic primitive function which returns a random partial permutation. The name ''Deal'' comes fr...")
 
Line 33: Line 33:
Deal depends on [[index origin]]. In particular, it picks k numbers from [[Index Generator|1 to n]] if <source lang=apl inline>⎕IO←1</source>, and from 0 to n-1 if <source lang=apl inline>⎕IO←0</source>.
Deal depends on [[index origin]]. In particular, it picks k numbers from [[Index Generator|1 to n]] if <source lang=apl inline>⎕IO←1</source>, and from 0 to n-1 if <source lang=apl inline>⎕IO←0</source>.


The choices made by Deal do not have to be truly random: they may be pseudorandom (generated by a deterministic but difficult to predict algorithm) or taken from the operating system. They way random numbers are generated is controlled by the [[random link]] <source lang=apl inline>⎕RL</source>. Note that using pseudorandom numbers for Deal may not be ideal for generating large permutations, since the possible number of permutations generated is bounded by the cycle length of the random number generator used.
The choices made by Deal do not have to be truly random: they may be [[wikipedia:pseudorandom|pseudorandom]] (generated by a deterministic but difficult to predict algorithm) or taken from the operating system. They way random numbers are generated is controlled by the [[random link]] <source lang=apl inline>⎕RL</source>. Note that using pseudorandom numbers for Deal may not be ideal for generating large permutations, since the possible number of permutations generated is bounded by the cycle length of the [[wikipedia:random number generator|random number generator]] used. Traditionally, APL uses the [[wikipedia:Lehmer random number generator|Lehmer random number generator]], but [[Dyalog APL]] defaults to the allow choosing a different random number generator and defaults to the [[wikipedia:Mersenne Twister|Mersenne Twister]].


== External links ==
== External links ==

Navigation menu