random_state {decisionSupport}R Documentation

Draw a random state for a categorical variable

Description

This function draws a sample from a user-defined frequency distribution for a categorical variable.

Usage

random_state(states, probs)

Arguments

states

character vector containing state names.

probs

numeric vector containing probabilities for the states. If these do not add up to 1, they are automatically normalized.

Value

one of the states, drawn randomly according to the specified probabilities.

Author(s)

Eike Luedeling

Examples


random_state(states=c("very low","low","medium","high","very high"),
  probs=c(1,1,2,1,1))


[Package decisionSupport version 1.114 Index]