On 22/10/2009, at 8:25 AM, carol white wrote:
Hi,
To generate random numbers between 0 and 1, do you use rnorm
followed by dnrom? for ex, for 10 variables
a = rnorm(10)
a
[1] -0.87640764 -0.95842391 -1.33434559 -0.63844932 -1.69829393
0.80010865
[7] -0.01026882 -0.23887516 2.29912600 -1.38352143
dnorm(a)
[1] 0.27171985 0.25202507 0.16378878 0.32538464 0.09432211 0.28966637
[7] 0.39892125 0.38772103 0.02838403 0.15320103
Well, this will give you random (in some sense) numbers between 0 and 1.
(Actually they will be between 0 and dnorm(0) = approx. 0.3989.)
Just what the *distribution* of these numbers would be is obscure to me.
You should also be aware that the values of dnorm() could be *larger*
than 1, if the standard deviation were specified to be something smaller
than the default value of 1. (Note that dnorm() is a ***density***,
not a probability function.)
Anyway this is a very convoluted way of going at the problem. Why
not just generate random numbers between 0 an 1 ``directly'', using
runif()?
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
______________________________________________
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.