RandomSample

RandomSample[{e1, e2, ...}, n]
gives a pseudorandom sample of n of the .

RandomSample[{w1, w2, ...}->{e1, e2, ...}, n]
gives a pseudorandom sample of n of the chosen using weights .

RandomSample[{e1, e2, ...}]
gives a pseudorandom permutation of the .

DetailsDetails

  • RandomSample[{e1, e2, ...}, n] never samples any of the more than once.
  • RandomSample[{e1, e2, ...}, n] samples each of the with equal probability.
  • RandomSample gives a different sequence of pseudorandom choices whenever you run Mathematica. You can start with a particular seed using SeedRandom.
  • A Method option to SeedRandom can be given to specify the pseudorandom generator used.
New in 6
New to Mathematica? Find your learning path »
Have a question? Ask support »