coin.toss {jmuOutlier} | R Documentation |
Coin Toss
Description
Graphs a simulation of the sample proportion of heads.
Usage
coin.toss(n, p=0.5, burn.in=0, log.scale=FALSE, col=c("black","red"), ...)
Arguments
n |
An integer denoting the number of times the coin is tossed. |
p |
The probability of heads, which must be between 0 and 1. |
burn.in |
An integer denoting the number of initial coin tosses which should be omitted from the graph. |
log.scale |
Logical; indicating whether or not the x-axis should have a logarithmic scale. |
col |
A vector of two colors, where the first color is used for the graph of the sample proportions,
and the second color is used for the horizontal line occurring at the value |
... |
Optional arguments to be passed to the |
Details
This function coin.toss
illustrates the Law of Large Numbers for proportions,
by simulating cumulative sample proportions.
Using nonzero burn.in
typically reveals greater precision in the graph
as the number of coin tosses increases.
Author(s)
Steven T. Garren, James Madison University, Harrisonburg, Virginia, USA
Examples
par( mfrow=c(2,2) )
coin.toss( 600, 0.5 )
coin.toss( 3e4, 0.4, )
coin.toss( 3e4, 0.7, 1000, col=c("hotpink","turquoise") )
coin.toss( 7e4, 0.3, 1000, TRUE, col=c("purple","green") )
par( mfrow=c(1,1) )