Skip to content

sampleConstrainedPair(random, options): readonly [number, number]

Defined in: packages/sampling/src/sample-pair.ts:54

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.

RandomSource

ConstrainedPairOptions

readonly [number, number]

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.

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