In: Math
Use SAS. Please include the code and the answers.
1. Generate 625 samples of size 961 random numbers from U(1, 9).
For each of these 625 samples calculate the mean:
a) Find the simulated probability that the mean is between 5 and 5.2.
b) Find the mean of the means.
c) Find the standard deviation of the means.
d) Draw the histogram of the means.
Sas Code:
/* Here we have to generate 625 samples of size 961 from U(1,9)*/
/* Here a = 1 and b = 9 */
%let ns = 961; /* sample size */
%let n = 625; /* Number of samples*/
%let a =1;
%let b= 9;
data a(keep =s1-s&n) ;
array s{&n};
do j = 1 to &ns;
do i = 1 to &n;
u=rand("uniform"); *Sample from uniform;
x = &a+ (&b-&a)*u;
s{i} = x;
end;
output;
end;
run;
/* Calculating mean for each sample s1 to s625*/
proc means data = a mean ;
var s1-s&n;
output out = b;*(drop = _:);
run;
* a);
data c(keep = prob );
set b(firstobs=4 obs = 4);
array s{&n};
cnt=0;
do i = 1 to &n;
if s{i} > 5 and s{i}<5.2 then cnt = cnt+1;
end;
prob = cnt/&n;
run;
/*Mean of means and standard deviation*/
*b,c);
proc transpose data =b(drop = _: firstobs = 4 obs=4) out = d;
run;
proc means data = d mean std;
output out = e;
run;
/*d*/
proc univariate data =d;
histogram col1;
run;