Learn R Programming

droll (version 0.1.0)

roll: The roll distribution

Description

Density, distribution function, quantile function, and random generation for the discrete distribution described by a roll expression. See below for more details.

Usage

droll(x, roll)

proll(q, roll, lower.tail = TRUE)

qroll(p, roll, lower.tail = TRUE)

rroll(n, roll)

Arguments

x

A numeric vector of outcomes.

roll

A roll expression (e.g., 2 * d6 + 5) or a data frame returned by r().

q

A numeric vector of outcomes.

lower.tail

Whether to calculate P[X <= x] or P[X > x].

p

A numeric vector of probabilities.

n

Number of random deviates to return.

Value

A numeric vector.

Details

Given a roll expression (i.e., an arithmetic expression involving dice), r() calculates the complete distribution of the outcomes. This is possible because the distribution is discrete and has a finite number of outcomes.

From this distribution, droll() returns the density, proll() returns the distribution function, qroll() returns the quantile function, and rroll() generates random deviates. They mirror functions from the Distributions family.

For more details on roll expressions, see r() and the Dice S4 class.

See Also

r(), Dice, roll-plot.

Examples

Run this code
# NOT RUN {
set.seed(42)

# Density of 2d6 + 5
droll(12, 2 * d6 + 5)

# Distribution function of 2d6 + 5
proll(12, 2 * d6 + 5)

# Quantile function of 2d6 + 5
qroll(0.5, 2 * d6 + 5)

# Roll 2d6 + 5 (generate random deviate)
rroll(1, 2 * d6 + 5)
# }

Run the code above in your browser using DataLab