# Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.
BUILT-IN WOLFRAM LANGUAGE SYMBOL

# RandomSample

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

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

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

## 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[{e1,e2,},UpTo[n]] gives a sample of n of the ei, or as many as are available.
• RandomSample[i;;j;;k,n] may be used to sample the Span from i to j in steps of k.
• RandomSample gives a different sequence of pseudorandom choices whenever you run the Wolfram Language. You can start with a particular seed using SeedRandom.
• A Method option to SeedRandom can be given to specify the pseudorandom generator used.

## ExamplesExamplesopen allclose all

### Basic Examples  (3)Basic Examples  (3)

Find a sample in which no elements ever occur more than once:

 In[1]:=
 Out[1]=

Generate a random permutation:

 In[1]:=
 Out[1]=

Generate a random sample of 6 elements, or as many as there are if fewer:

 In[1]:=
 Out[1]=