Skip to contents

Calculates probability of at least one occurrence of an event given the number of attempts.

Usage

dry_calc(p, n, verbose = TRUE, plot = TRUE)

Arguments

p

Numeric probability of event occurrence.

n

Integer indicating the number of attempts.

verbose

Controls format of returned probability; Default (TRUE) prints result as a chr statement; FALSE returns result as a numeric decimal.

plot

Controls printing of plot showing where the resulting probability lies on the binomial distribution; Default (TRUE) shows the plot.

Value

A number, the probability of at least one occurrence of the event given the number of trials is returned as a decimal (if verbose set to FALSE).

Examples

# return numeric probability and show plot
dry_calc(0.2, 5L, verbose = FALSE, plot = TRUE)

#> [1] 0.67232
# return probability in a chr statement and don't show plot
dry_calc(0.5, 3L, verbose = TRUE, plot = FALSE)
#> [1] "There is a 87.5% chance of the event occurring at least once after you play 3 attempts."