draw_categorical: Draw a categorical index from probabilities

View source: R/utilities.R

draw_categoricalR Documentation

Draw a categorical index from probabilities

Description

Given a uniform random draw and a vector of probabilities, returns the 1-based integer index of the selected category.

Usage

draw_categorical(luck, probs)

Arguments

luck

Numeric between 0 and 1 (inclusive). A uniform random draw.

probs

Numeric vector of probabilities. Will be normalized to sum to 1 internally. All values must be >= 0.

Value

Integer: 1-based index of the selected category.


WARDEN documentation built on July 23, 2026, 5:08 p.m.