[R] sampling from normal

Wu Gong wg2f at mtmail.mtsu.edu
Wed Oct 20 04:36:24 CEST 2010


Hi Solafah,

You are right that two commands are equivalent when p= pnorm(a). You can
check the results by following codes.
n <- 5
a <- -1
set.seed(123456)
qnorm(runif(n,0,pnorm(a)))
p <- pnorm(a)
set.seed(123456)
qnorm(p*runif(n)) 

Anyway, the elements of the lower tail are not chosen equally by this
method. I may try another method. Such like:
s1 <- rnorm(10000)
n <- 5
a <- -1
sample(s1[s1<a],n)


-----
A R learner.
-- 
View this message in context: http://r.789695.n4.nabble.com/sampling-from-normal-tp3003016p3003164.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list