coin_flip: Coin flip

Description Usage Arguments Details Value Examples

Description

Simulates a coin flip.

Usage

1
coin.flip(coins = 5, flips = 100, weights = c(0.5, 0.5), getExact)

Arguments

coins

The number of coins to flip. If unspecified, it defaults to 5.

flips

The number of flips. If missing, it defaults to 100.

weights

A vector of probability weights to assign to each face of the coin; if unspecified, it defaults to a fair coin with equally likely faces. If specified, its lenght must obviously be a vector of length two whose values sum up to 1.

getExact

A vector containing values to be matched exactly, namely the function returns only those combinations containing all the above mentioned variables. Since this is a coin flip, values must be specified in the form c("H", "H", "T") as head and tails (make sure to provide the labels in quotation marks).

Details

The function is a particular case of dice.roll, namely a roll with 2 faces and 1 die.

Value

A table containing the frequencies for each of the two occurrences (head and tail) after the specified number of flips.

Examples

1
coin.flip(coins = 5, flips = 100)

Example output

   value_1 value_2 value_3 value_4 value_5 freq
1:       H       H       H       H       H 0.01
2:       H       H       H       H       T 0.19
3:       H       H       H       T       T 0.28
4:       H       H       T       T       T 0.38
5:       H       T       T       T       T 0.13
6:       T       T       T       T       T 0.01

Rdice documentation built on May 2, 2019, 3:46 a.m.