Skip to content
Prev 258356 / 398502 Next

how to generate a normal distribution with mean=1, min=0.2, max=0.8

Good point.  It would be absurdly inefficient if the upper and lower 
limits on the interval of interest were, say, 0.2 and 0.201 instead of 0.2 
and 0.8.  Here's what I think is probably the best general approach:

Compute the CDF for the upper and lower limits of the interval and 
generate uniform random numbers within that range of CDF values, then 
compute the inverse CDF of those values.  To be explicit:

n <- 1000
L <- .2
U <- .8

p_L <- pnorm(L)
p_U <- pnorm(U)

x <- qnorm(runif(n, p_L, p_U))

It is very fast and it always produces exactly the desired number ("n") of 
random normal values.

Mike

--
Michael B. Miller, Ph.D.
Bioinformatics Specialist
Minnesota Center for Twin and Family Research
Department of Psychology
University of Minnesota
On Thu, 28 Apr 2011, Carl Witthoft wrote: