Simulation Experiments
摘要
Simulation is a versatile tool to investigate the probability distribution of an outcome of a random event or experiment. In this chapter we focus on R functions that simplify the design and implementation of common types of simulation studies. Two functions that are used throughout are the sample() function for drawing random samples with or without replacement, and the replicate() function to easily repeat blocks of code including the sampling. The examples include some famous probability problems such as the collector’s problem and the hat-check problem, and the streaky patterns found among hitters in a baseball game. Simulations are summarized with suitable plots in R graphics and ggplot graphics.