I'm going to talk about simulation in this lecture.

Simulation's a very important topic for statistics and

for a number of other applications, so I

just want to introduce some of the functions in

R that can be useful for doing simulation.

So, there are a couple of functions that are available for simulating numbers or

variables from given probability distributions, probably the

most important of which is the normal distribution.

And so we can generate variates

from the normal distribution by specifying a mean and a

standard deviation for that distribution and then calling the rnorm function.

So the rnorm function will simulate normal random variables that

from a distribution has a given mean and standard deviation.

So the, there's a cor, there are

corresponding functions for the R, for the normal

distribution that can be used to evaluate

the probability density, to evaluate the cumulative distribution

function and for also for evaluating the quantile function.

So, another function for generating random variables is the rpoirs function or the,

which generates Poisson random variables from

a Poisson distribution with a given rate.

And so, so there are number of functions for generating

random variables from the, from kind of the standard probability distributions.

And you can use these to do, to run simulations.

So, probability distribution functions ha, there

are basically four functions associated with them.

And so for any given distribution like the

normal distribution there will be a function that

starts with the d, a function that starts with an r, a p, and a q.

So there'll be four different functions for each distribution.

So we've ready, I've already mentioned that there's the rnorm function.

The rnorm function is for generating the, is for random number generation.

There's a dnorm

function, which evaluates the density of the probability

dist distribution for given mean and standard deviation.

There's the pnorm function, which evaluates the cumulative distribution.

And there's the qnorm function, which evaluates the quantile function.

So every distribution has these four types of functions.

So for the gamma distribution, there'll be a

dgamma, an rgamma, pgamma, and a qgamma function.

And for the Poisson distribution

there's the rpoise dpoise ppoise, and qpoise functions.