sampleIndices(
random,populationSize,sampleSize): readonlynumber[]
Defined in: packages/sampling/src/sample-indices.ts:17
Sample a uniform subset of 0..populationSize - 1 in ascending order.
Floyd’s algorithm uses O(sampleSize) expected auxiliary space, followed by an O(sampleSize log sampleSize) canonical sort. The inputs are not mutated.
Parameters
Section titled “Parameters”random
Section titled “random”populationSize
Section titled “populationSize”number
sampleSize
Section titled “sampleSize”number
Returns
Section titled “Returns”readonly number[]
Throws
Section titled “Throws”With code INVALID_POPULATION_SIZE when
populationSize is not a safe integer in 0..2^32, or
INVALID_SAMPLE_SIZE when sampleSize is not representable or exceeds the
population.
Throws
Section titled “Throws”With code INVALID_SOURCE_VALUE when the
random source returns a value outside [0, 1).