categorical
categorical(
options):NumberSampler
Defined in: src/distribution/discrete/bernoulli.ts:77
Categorical: an index in [0, weights.length), proportional to the weights. Uses Vose’s alias method, so each draw is O(1).
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Example
Section titled “Example”const tier = categorical({ weights: [1, 3, 6] });tier.sample(); // 2, most of the time