[R] simple random number generation

S Ellison S.Ellison at lgc.co.uk
Fri Jul 25 05:07:01 CEST 2008

Since the standard normal distribution goes to infinity in both
directions, you can't have random normal constrained to +-1.5.

You can have _truncated_ standard normal, though, if that's really what
you want. 

+-1.5 is/are the normal quantiles at pnorm(c(-1.5,1.5)). So if we
generate 500 uniformly distributed probabilities in the range
pnorm(c(-1.5,1.5)), and then run qnorm on those,  you should get what
you want:

Try this:

lims<-pnorm(c(-1.5,1.5)) #get the range of probs required

Steve E.

>>> dxc13 <dxc13 at health.state.ny.us> 07/25/08 12:35 AM >>>


I want to randomly generate 500 numbers from the standard normal
distribution, i.e. N(0,1), but I only want them to be generated in the
-1.5 to 1.5.  Does anyone have a simple way to do this?


View this message in context:
Sent from the R help mailing list archive at Nabble.com.

R-help at r-project.org mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

This email and any attachments are confidential. Any use...{{dropped:8}}

More information about the R-help mailing list