Date: Tue, 4 Oct 2005 16:40:39 -0400
Reply-To: Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject: Re: draw a normal distribution (also lognormal)
On Tue, 4 Oct 2005 13:21:08 -0700, David L Cassell <davidlcassell@MSN.COM>
wrote:
>depuy001@NOTES.DUKE.EDU replied:
>>I believe the following will create a normal distribution (with mean 0 and
>>std dev 1) Note that it looks much more normal if you use 1000 points,
etc.
>>If you want to get particular, you can have Proc Univariate draw in lines
>>for what a normal and/or lognormal distribution, with the mean/std dev of
>>the data, should look like.
>>
>>data file1;
>> do i = 1 to 100;
>> j = rannor(i);
>> k = exp(j);
>> output;
>> end;
>>
>>run;
>
>This will produce 100 normal(0,1) variates.
>
>Whether there will be a covariance problem is a harder issue. I can't tell
>at
>first glance.
>
>The problem is that the parameter for rannor [as for the rest of the random
>variate functions and call routines] is the SEED. It's not a counter. So
>this
>would really be better if you declared a (randomly chosen) seed to start
>with,
>and let SAS manage the (pseudo) random number stream internally:
>
>data file1;
> SEED = 59678463;
> do i = 1 to 100;
> j = rannor(SEED);
> k = exp(j);
> output;
> end;
> run;
>
>
>To get a random variate from a normal(mu, sigma**2) distribution, all
>you have to do is:
>
>
>data file1;
> SEED = 59678463;
> mu=10;
> sigma=7;
>
> do i = 1 to 100;
> j = mu + sigma * rannor(SEED);
> output;
> end;
> run;
>
>
>I don't know if Venita's approach puts you at risk of mucking up the stream
>for
>the PRNG (Pseudo-Random Number Generator), but forcing a specific sequence
>from the PRNG sounds like a bad idea. I'm sure someone on SAS-L will be
>motivated enough to sit down and run off 100,000 variates using Venita's
>schema
>and check them against a few dozen of the random-number tests, just to see.
Hi, David,
You are correct (as always). I am sure this topic has been discussed
multiple times on sas-l. Here is the most recent one I can find:
http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0507C&L=sas-l&D=1&O=D&P=48609
Cheers,
Chang
|