Date: Tue, 4 Oct 2005 13:21:08 -0700
Reply-To: David L Cassell <davidlcassell@MSN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: David L Cassell <davidlcassell@MSN.COM>
Subject: Re: draw a normal distribution (also lognormal)
In-Reply-To: <200510040436.j94321Qg027207@mailgw.cc.uga.edu>
Content-Type: text/plain; format=flowed
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.
David
--
David L. Cassell
mathematical statistician
Design Pathways
3115 NW Norwood Pl.
Corvallis OR 97330
_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/