g...@ucalgary.ca wrote:
Please forget the last email I sent with the same subject.
=================
I would like to generate pseudo-random numbers between two numbers using
R, up to a given distribution,
for instance, norm. That is something like rnorm(HowMany,Min,Max,mean,sd)
over rnorm(HowMany,mean,sd).
I am wondering if

qnorm(runif(HowMany, pnorm(Min,mean,sd), pnorm(Max,mean, sd)), mean, sd)

is good.


It depends on what Min and Max are. If you get far out in the tails, rounding error will kill you. For example, pnorm(x) is exactly 1 for x bigger than 10 or so, so this approach would fail if Min and Max were both bigger than 10. The solution is to switch to lower=FALSE in the upper tail, and possibly switch to a log scale if you want to be really extreme.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to