getOutcomeProb {dice} | R Documentation |
For a specified dice-rolling process, getOutcomeProb
calculates the probability of an outcome (actually, in technical terms, an event consisting of a non-empty set of outcomes) that is specified by passing a list
object in to outcomeList
.
getOutcomeProb(ndice, nsides, outcomeList, orderMatters = FALSE)
ndice |
A single positive integer representing the number of dice to roll |
nsides |
A single positive integer representing the number of sides on each die (getOutcomeProb 's dice-rolling process involves only one type of die per call) |
outcomeList |
A list object, each element of which is a vector that constrains a single die in the dice-roll (see Details below) |
orderMatters |
A logical flag indicating whether the order of the elements of outcomeList should constrain the outcome space; if TRUE, outcomeList must specify constraints for every die roll–i.e., it must contain exactly ndice elements (some of which may be "empty" constraints of the form 1:n , where n is the same value passed in to nsides ) |
The crux of this function is outcomeList
, which sets the conditions that acceptable dice-rolls must meet. E.g., to get the probability of rolling at least one 6 when rolling four six-sided dice, outcomeList
would be list(6)
and orderMatters
would be FALSE; to get the probability of rolling a 6, followed by a 5, followed by either a 1, 2, or 3 when rolling three six-sided dice, outcomeList
would be list(6,5,1:3)
and orderMatters
would be TRUE.
A single number representing the probability of getting an outcome that meets the constraints of the specified dice-rolling process
Dylan Arena
## Probability of rolling at least one 6 when rolling four six-sided dice getOutcomeProb(ndice = 4, nsides = 6, outcomeList = list(6)) ## Probability of rolling a 6, followed by a 5, followed by either a 1, 2, ## or 3 when rolling three six-sided dice getOutcomeProb(ndice = 3, nsides = 6, outcomeList = list(6, 5, 1:3), orderMatters = TRUE) ## Probability of rolling no 10's when rolling two ten-sided dice getOutcomeProb(ndice = 2, nsides = 10, outcomeList = list(1:9,1:9))