# sampleConstrainedPair

> **sampleConstrainedPair**(`random`, `options`): readonly \[`number`, `number`]

Defined in: [packages/sampling/src/sample-pair.ts:54](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/sampling/src/sample-pair.ts#L54)

Sample uniformly from ascending integer pairs whose gap is in the inclusive interval `[minimumGap, maximumGap]`.

Valid pairs are ranked by increasing gap and then increasing first index. Rank lookup takes O(log(maximumGap - minimumGap + 1)) time and O(1) auxiliary space. The options object is not mutated.

## Parameters

### random

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

### options

[`ConstrainedPairOptions`](/reference/knotkit/sampling/interfaces/constrainedpairoptions/)

## Returns

readonly \[`number`, `number`]

## Throws

With code `INVALID_RANGE` when bounds do not describe a supported range or the range contains more than 2^32 valid pairs, or `INVALID_GAP` when the gap interval is invalid for the range.

## Throws

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