Hi R gurus, How do I generate a random sample with a given variance? Thanks! __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
How do I generate a random sample with an given variance?
6 messages · pooh rondstr, Uwe Ligges, Duncan Murdoch +3 more
pooh rondstr wrote:
Hi R gurus, How do I generate a random sample with a given variance?
It depends. ;-) Assuming you want to generate a normal distributed random sample, have a look at ?rnorm Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 26 Mar 2001 11:29:13 -0800 (PST), you wrote in message <20010326192913.36803.qmail at web12001.mail.yahoo.com>:
Hi R gurus, How do I generate a random sample with a given variance?
Generate a random sample, then rescale it to have the variance you require. Duncan Murdoch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
pooh rondstr <poohtest at yahoo.com> writes:
Hi R gurus, How do I generate a random sample with a given variance?
Form the standard normal ... for 100 numbers with a mean of 5 and a
standard deviation of 2:
rnorm(100, mean = 5, sd = 2)
Mark
--
Mark Myatt
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
pooh rondstr <poohtest at yahoo.com> writes:
Hi R gurus, How do I generate a random sample with a given variance?
Form the standard normal ... for 100 numbers with a mean of 5 and a
standard deviation of 2:
rnorm(100, mean = 5, sd = 2)
hm, but R> x <- rnorm(100, mean = 5, sd = 2) R> mean(x) [1] 4.742486 R> var(x) [1] 3.398248 is clearly not what one wants. Better: R> x <- rnorm(100, mean = 5, sd = 2) R> x <- (x - mean(x))/sqrt(var(x)) R> mean(x) [1] 1.385177e-16 R> var(x) [1] 1 and now create your sample with mean 5 and sd 2: R> x <- x*2 + 5 R> mean(x) [1] 5 R> var(x) [1] 4 Torsten
Mark -- Mark Myatt -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear all, is it possible to have orizontal the y-title of a graph? Luca Laghi -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._