# sampleIndices

> **sampleIndices**(`random`, `populationSize`, `sampleSize`): readonly `number`\[]

Defined in: [packages/sampling/src/sample-indices.ts:17](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/sampling/src/sample-indices.ts#L17)

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

### random

[`RandomSource`](/reference/knotkit/prng/type-aliases/randomsource/)

### populationSize

`number`

### sampleSize

`number`

## Returns

readonly `number`\[]

## 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

With code `INVALID_SOURCE_VALUE` when the random source returns a value outside `[0, 1)`.
