Skip to main content
The Deno 2 Release Candidate is here
Learn more
method ProbabilityObjectArray.prototype.draw
import { ProbabilityObjectArray } from "https://deno.land/x/sptaki@1.2.0/utils/RandomUtil.d.ts";

Draw random element of the ProbabilityObject N times to return an array of N keys. Drawing can be with or without replacement

Parameters

optional
count: number

The number of times we want to draw

optional
replacement: boolean

Draw with or without replacement from the input dict (true = dont remove after drawing)

optional
locklist: Array<K>

list keys which shall be replaced even if drawing without replacement

Returns

K[]

Array consisting of N random keys for this ProbabilityObjectArray