These functions simplify simulating coin tosses for those (students primarily) who are not yet familiar with the binomial distributions or just like this syntax and verbosity better.
rflip(
n = 1,
prob = 0.5,
quiet = FALSE,
verbose = !quiet,
summarize = FALSE,
summarise = summarize
)
# S3 method for cointoss
print(x, ...)
nflip(n = 1, prob = 0.5, ...)
the number of coins to toss
probability of heads on each toss
a logical. If TRUE
, less verbose output is used.
a logical. If TRUE
, more verbose output is used.
if TRUE
, return a summary (as a data frame).
alternative spelling for summarize
.
an object
additional arguments
for rflip
, a cointoss object
for nflip
, a numeric vector
rflip(10)
#>
#> Flipping 10 coins [ Prob(Heads) = 0.5 ] ...
#>
#> T H H H H H T H T H
#>
#> Number of Heads: 7 [Proportion Heads: 0.7]
#>
rflip(10, prob = 1/6, quiet = TRUE)
rflip(10, prob = 1/6, summarize = TRUE)
#> n heads tails prob
#> 1 10 2 8 0.1666667
do(5) * rflip(10)
#> Using parallel package.
#> * Set seed with set.rseed().
#> * Disable this message with options(`mosaic:parallelMessage` = FALSE)
#> n heads tails prop
#> 1 10 5 5 0.5
#> 2 10 5 5 0.5
#> 3 10 6 4 0.6
#> 4 10 1 9 0.1
#> 5 10 6 4 0.6
as.numeric(rflip(10))
#> [1] 7
nflip(10)
#> [1] 5