# What do additional arguments indicate in the simple.sim function in R?

In R suppose that we have the following code:

 require("UsingR") # required for "simple.sim" function below
f= function(n=100,mu=0,sigma=1) {
nos = rnorm(n,mu,sigma)
(mean(nos)-mu)/(sigma/sqrt(n))
}

simulations = simple.sim(100,f,100,5,5)
hist(simulations,breaks=10,prob=TRUE)


Does this basically simulate 100 normal random variables with mean 5 and standard deviation 5? In the simulations argument, what do the 5's indicate?

-
Have you read the help page for simple.sim? – whuber May 15 '12 at 17:56
Is this homework? It should be tagged if it is. – Seth May 15 '12 at 20:31
Do you want to simulate normal random variables? It seems like you are after something more complicated, but I am not sure what. – Seth May 16 '12 at 4:43

When you look at the simple.sim() help page you see there are two arguments and an ellipsis("..."). The ellipsis allows you to pass any unspecified argument through simple.sim() into one of the nested functions, here f() and rnorm(). So you are getting mu is 5 and sigma is 5. It is pretty bad practice to pass unnamed arguments this way, so be careful!
@Seth: Let the $X_i$ be normal with $\mu =5$ and $\sigma= 5$. Then the function above should have $\mu = 5$ and $\sigma=5$ instead of $\mu=0$ and $\sigma=1$. So maybe it was just a typo. – user11347 May 16 '12 at 3:48
simulations = simple.sim(100,f,5,5) replaces $\mu = 0, \sigma = 1$ with $\mu = 5, \sigma=5$? – Damien May 16 '12 at 4:31