sampleWithReplacement
sampleWithReplacement(
x,n,randomSource?):any[]
Defined in: src/sample_with_replacement.js:14
Sampling with replacement is a type of sampling that allows the same item to be picked out of a population more than once.
Parameters
Section titled “Parameters”any[]
an array of any kind of value
number
count of how many elements to take
randomSource?
Section titled “randomSource?”Function
an optional entropy source that returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)
Returns
Section titled “Returns”any[]
n sampled items from the population
Example
Section titled “Example”var values = [1, 2, 3, 4];sampleWithReplacement(values, 2); // returns 2 random values, like [2, 4];