This function provides a simulation to the process of flipping coins and computes the frequencies for `heads' and `tails'.
flip.coin(
faces = 2,
prob = NULL,
border = "white",
grid = "white",
col = 1:2,
type = "p",
pch = 21,
bg = "transparent",
digits = 3
)
an integer or a character vector. See details below.
the probability vector of showing each face. If NULL
, each
face will be shown in the same probability.
The border style for the rectangles which stand for probabilities.
the color for horizontal grid lines in these rectangles
The colors to annotate different faces of the `coin'.
See points
.
integer indicating the precision to be used in the annotation of frequencies in the plot
A list containing
A vector of frequencies (simulated probabilities)
the total number of tosses
If faces
is a single integer, say 2, a sequence of integers from 1 to
faces
will be used to denote the faces of a coin; otherwise this
character vector just gives the names of each face.
When the \(i\)-th face shows up, a colored thin rectangle will be added to the corresponding place (the \(i\)-th bar), and there will be corresponding annotations for the number of tosses and frequencies.
The special argument grid
is for consideration of a too large number
of flipping, in which case if you still draw horizontal lines in these
rectangles, the rectangles will be completely covered by these lines, thus we
should specify it as NA
.
At last the frequency for each face will be computed and shown in the header
of the plot -- this shall be close to prob
if
ani.options('nmax')
is large enough.
Examples at https://yihui.org/animation/example/flip-coin/