Home
About R Trix
Teaching Resources
RTricks Library
Interactive Apps
Training Network
R Output for Discrete Probability Example 3
> fair.sim <- rbinom(100, 1, 0.5)
> heads.fair <- sum(fair.sim)/100
> biased.sim <- rbinom(100, 1, 0.8)
> heads.biased <- sum(biased.sim)/100
> compare <- data.frame(heads.fair, heads.biased)
> rownames(compare) <- "experimental probability"
> compare
heads.fair
heads.biased
experimental probability
0.5
0.86
> barplot(c(heads.fair, heads.biased), names.arg = c("Fair", "Biased"),
> ylab = "Number of Heads", main = "Number of Heads in 100 Simulated Flips")