Re: [R] help about random generation of a Normal distribution ofseveral variables

From: <Bill.Venables_at_csiro.au>
Date: Sun, 06 Jul 2008 15:23:29 +1000

> 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.

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. Received on Sun 06 Jul 2008 - 05:31:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 06 Jul 2008 - 06:31:44 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive