BookmarkSubscribeRSS Feed
valarievil
Obsidian | Level 7

I need to use SAS to answer the following:

  1. Suppose Xi for i=1, 2, 3… has uniform (0, 1) distribution. Let M = min (n: X1 + X2 + … + Xn> 1). Find expected value of M; E(M) = Mean of M. If there is convergence, why and what is the final answer. However, if there is divergence, explain.

I was able to generate E(M) with the following code:

data prob1;
call streaminit (33);
do i=1 to 10000;
   sum=0 ;
   M=0 ;
   do until (sum>1) ;
      xuni = rand('uniform', 0, 1);
      sum+xuni;
      M+1 ;
   end ;
   output;
end;
run;
proc means data=prob1;
var M;
run;

 But I am completely lost as to whether or not there is convergence. I don't think I understand exactly what is expected of me. convergence of E(M)? I'm lost please help!

2 REPLIES 2
PGStats
Opal | Level 21

Play with the following:

 

data prob1;
call streaminit (33);
do k = 2 to 12;
	do rep = 1 to 8;
		do i = 1 to 2**k;
		    sum = 0 ;
		    M = 0 ;
		    do until (sum > 1) ;
		        xuni = rand('uniform', 0, 1);
		        sum + xuni;
		        M + 1;
		        end ;
		    output;
		 	end;
		end;
	end;
keep k rep M;
run;

proc summary data=prob1;
by k rep;
var M;
output out=prob2 mean=meanM;
run;

proc sgplot data=prob2;
scatter x=k y=meanM / jitter;
xaxis integer;
run;

UniformConverge.png

PG

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 809 views
  • 2 likes
  • 2 in conversation