Sounds like a homework problem or an exam. Well, here are the parts needed to answer it. The student can then use these parts to get the final answer.

- a) format for random normal function is:
__rnorm(n, mean = 0, sd = 1)__where**n**is number of numbers to be generated.**mean**is the mean for the sample, and**sd**= standard deviation

b) basic format for histogram is:__ hist(x)__ where **x** = vector with numbers in it

the following example would generate 1000 samples from a population of mean 20 and standard deviation of 5 then plot a histogram

* x<-rnorm(1000,20,5)*

* hist(x)*

2,a) the 'for loop' has the following format :__ for ( i in b:e) { executable code }__

where** i **is the index which increments from **b** to **e**

b) the sample function will pull samples from a population and put them in a named variable. its format is:

__sample(x, size, replace = FALSE)__. Where **x** is name of variable/vector with values to sample.** size **is the number of samples to take, **replace =** indicates if the sampling will be done with or without replacement.

c). the mean function will generate the mean of the values in a vector variable. The format is:

__mean(x)__

d) to create a vector of a series of means, you will use the concatenate function __c(x1,x2,...x4)__

an example of code that would use these to put together a vector with the mean of 25 random samples is:

(note: since it wasn't specified , we do sampling with replacement to maintain population)

*x1 = NULL*

*for (i in 1:25) {*

* s = sample(x,40, replace=TRUE)*

* m = mean(s)*

* x1<- c(x1,m)*

*}*

*hist(x1)*

3 For this question the new function you will need will be standard deveation. sd().

sd(x). where x is vector variable. calculates standard deviation of the values in x

Remember , if you followed the above examples you would have two vectors of numbers. X. is a vector of 1500 random numbers. X1 is a vector of the MEANS of samples of X. The standard deviation of X would be the standard deviation of the population. The standard deviation of X1 would be the standard error of the sample means. They will vary. an example of how to examine the mean and standard deviation and distribution of these two different vectors is as follows

*mean(x)*

*sd(x)*

*mean(x1)*

*sd(x1)*

*hist(x)*

*hist(x1)*

David B.

04/26/21

Leo N.

Thank you this is a homework assignment that I was never able to understand/solve and I wanted to understand before the final exam. Thanks!04/26/21