roll-plot {droll}R Documentation

Plot the roll distribution

Description

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

Usage

droll_plot(roll, ...)

proll_plot(roll, lower.tail = TRUE, ...)

qroll_plot(roll, lower.tail = TRUE, ...)

rroll_plot(n, roll, ...)

Arguments

roll

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

...

Other arguments passed on to plotting functions (graphics::barplot() or ggplot2::qplot() if available).

lower.tail

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

n

Number of random deviates to return.

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_plot() plots the density, proll_plot() plots the distribution function, qroll_plot() plots the quantile function, and rroll_plot() plots random deviates.

For more information, see the generating functions: roll.

Value

For droll_plot(), proll_plot(), and qroll_plot() a bar plot. For rroll_plot() a histogram.

See Also

graphics::barplot(), ggplot2::qplot(), d(), roll

Examples

set.seed(42)

# Density of 2d6 + 5
droll_plot(2 * d6 + 5)

# Distribution function of 2d6 + 5
proll_plot(2 * d6 + 5)

# Quantile function of 2d6 + 5
qroll_plot(2 * d6 + 5)

# Roll 2d6 + 5
rroll_plot(1000, 2 * d6 + 5)

[Package droll version 0.1.0 Index]