help about random generation of a Normal distribution ofseveral variables
library(MASS) set.seed(22134) Y <- mvrnorm(100, mu = c(0,1), Sigma = matrix(c(2,1,1,3),2,2)) colMeans(Y)
[1] 0.06461359 1.08436419
var(Y)
[,1] [,2] [1,] 1.683963 1.300363 [2,] 1.300363 3.280612
Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:Bill.Venables at csiro.au http://www.cmis.csiro.au/bill.venables/ -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Arnau Mir Torres Sent: Sunday, 6 July 2008 2:14 AM To: r-help at r-project.org Subject: [R] help about random generation of a Normal distribution ofseveral variables Hello. Somebody knows how can I generate a set of n random vectors of a normal distribution of several variables? For example, I want to generate n=100 random vectors of two dimensions for a normal with mean c(0,1) and variance matrix: matrix(c(2,1,1,3),2,2). Thanks in advance, Arnau. ______________________________________________ R-help at 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.