13 Simulation Basics

Reminders: R is picky in its notation; you need to distinguish between upper/lower case. There are many ways of doing the same thing in R.

Type the code provided below in a R script to see the results. Typing is better than copying the code, as you might make a mistake in typing that allows you to learn how to debug your coding.

Simulation is a method used to examine the “what if” without having real data. We just make it up! We can use pre-programmed functions in R to simulate data from different probability distributions or we can design our own functions to simulate data from distributions not available in R.

This chapter illustrates a few built-in functions to generate values from particular probability distributions. Methods to generate these values are beyond the scope of this chapter, as well as simulating values using methods other than with probability distributions.