sample(Object array, Integer size, Boolean replace)

The sample function uniformly sample the subset of a given size from an array of the elements either with or without the replacement.

Parameters

  • Object array - 1d-array to be sampled.
  • Integer size - the number of elements to choose.
  • Boolean replace - (optional) If replace is true, the same element can be sampled multiple times, if false (as default), it can only appear once in the result.

Return type

Object