BookmarkSubscribeRSS Feed
fibonacheese
Calcite | Level 5

Hi, I am not sure how to get started on this question:

 

  1. Generate 2000 samples of size 40000 random numbers from a Poisson distribution with lambda = 8. For each of these 2000 samples calculate the mean.

so far I have 

 

data poisson;
call streaminit (0);
psamples = 2000;
psizesamp = 40000;
lambda = 8;
do psample = 1 to psamples;


      do n2 = 1 to psizesamp;

 

      end;

 

end;

 

I understand that I will need to use a nested loop, but I do not know how to set up poisson distribution. I imagine it is somewhat similar to uniform distribution. Anyone know how I would do that or any resources to look at! Thank you

2 REPLIES 2
PGStats
Opal | Level 21

Get a random Poisson value with:

 

x = rand("Poisson", lambda);

PG
KachiM
Rhodochrosite | Level 12

@fibonacheese 

 

As indicated by @PGStats  try the following:

 

data poisson;
   call streaminit (0);
   retain sumy meantotal;
   psamples = 20; *2000;
   psizesamp = 40000;
   lambda = 8;
   do psample = 1 to psamples;
      sumy = 0;
      do n2 = 0 to psizesamp;
         y = rand("Poisson", lambda);
         sumy + y;
      end; 
      mean = sumy / psizesamp;
      meantotal + mean;
      *output;
   end;
   mom = meantotal / psamples;
   put 'Mean of the Means ' mom;
run;

See the commented statements for lesser / no output. A better way is to keep out the initial values as macro variables for not to load them into PDV as:


%let lambda = 8;
%let psamples = 2000;
%let psizesamp = 40000;

 

and inserting them into the code.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 511 views
  • 0 likes
  • 3 in conversation