[R] Generate variable with Bivariate Normal Distribution

Gregor mailinglist at gmx.at
Wed Oct 20 08:56:32 CEST 2010

You could e.g. use the package "mvtnorm" (not horribly fast, but handy):

(assuming that rho is the correlation)

m <- c(mean1, mean2) #mean vector
cov <- rho*sqrt(variance1*variance2)
sig <- matrix(c(variance1, cov, cov, variance2), nrow=2) #covariance matrix
rmvnorm(100, mean=m, sigma=sig)

alternatively, you can transform manually via sigma^(1/2) (faster). This is covered
in almost any (multivariate) statistics book.


On Wed, 20 Oct 2010 12:29:53 +0700
สถาบันวิจัยและพัฒนา มหาวิทยาลัยราชภัฏอุบลราชธานี <ird_ubru at hotmail.com> wrote:

> Dear All
>     I want to generate variable with Bivariate Normal Distribution by 
> use mean1 = a, variance1 = b, mean2 = c, variance2 = d, rho = e.
>      How I can do this.
> Many Thanks.
> IRD 		 	   		  
> 	[[alternative HTML version deleted]]
> ______________________________________________
> 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.

More information about the R-help mailing list