Learn R Programming

asbio (version 0.3-1)

coin.flip: Demonstration of frequentist convergence of probability with a coin flip.

Description

Creates an animated plot shsowing results from coin flips and the resulting converence in the probability of a head as the number of flips goes large.

Usage

coin.flip(flips = 1000, p.head = 0.5, interval = 0.01, cex.axis = 1, ...)

Arguments

flips
The number of desired coin flips.
p.head
User defined probability of a head; e.g. for a fair coin p.head = 0.5.
interval
The time between animation frames, in seconds.
cex.axis
Character exapansion for axis.
...
Additional arguments from link{plot}.

Value

  • Returns two plots configured as a single graphical object. The first plot shows individual outcomes of coin flips given p.head, defined by the user. The second shows convergence in estimated P(Head), i.e. number of heads/number of trials, as the number of trials grows large.

See Also

rbinom

Examples

Run this code
coin.flip(1000)

Run the code above in your browser using DataLab