In: Statistics and Probability
Consider a bivariate normal distribution with ?1 = 10, ?2 = 15, ?11 = 2, ?22 = 3, ?12 = −0.75. Write out the bivariate normal density, ? (?, ?).
Round your answers to 3 significant digits
I need R code for this question, Thanks
To simulate data from bivariate normal density, the R code is following
library(MASS)
rbvn <- function (n, m1, s1, m2, s2, rho)
{
X1 <- rnorm(n, m1, s1)
X2 <- rnorm(n, m2 + (s2 / s1) * rho * (X1 - m1), sqrt((1 -
rho^2)*s2^2))
cbind(X1, X2)
}
n = 50
m1 = 10
s1 = 2
m2 = 15
s2 = 3
rho = -0.75
bvn <- round(rbvn(n, m1, s1, m2, s2, rho), digits = 3)
bvn
and the output is
X1 X2
[1,] 13.781 12.786
[2,] 10.012 15.373
[3,] 13.067 9.535
[4,] 9.875 16.063
[5,] 13.196 11.386
[6,] 11.630 12.308
[7,] 13.736 6.758
[8,] 10.521 12.999
[9,] 10.078 17.603
[10,] 11.149 12.900
[11,] 6.344 16.213
[12,] 10.657 12.273
[13,] 8.568 14.822
[14,] 8.436 16.769
[15,] 10.426 14.135
[16,] 9.249 17.114
[17,] 5.186 18.973
[18,] 10.527 13.603
[19,] 12.657 15.942
[20,] 10.712 12.973
[21,] 10.115 13.875
[22,] 8.989 16.745
[23,] 11.551 15.501
[24,] 8.066 14.914
[25,] 5.203 18.282
[26,] 10.334 11.601
[27,] 13.873 13.162
[28,] 9.971 13.897
[29,] 11.700 12.928
[30,] 8.699 13.896
[31,] 9.889 16.742
[32,] 10.398 14.120
[33,] 9.332 17.512
[34,] 13.133 10.401
[35,] 8.197 15.812
[36,] 8.624 13.157
[37,] 10.818 16.472
[38,] 6.556 20.276
[39,] 11.271 14.877
[40,] 11.067 11.225
[41,] 5.481 20.812
[42,] 10.700 13.858
[43,] 11.519 14.185
[44,] 11.738 13.794
[45,] 8.811 17.015
[46,] 11.944 10.013
[47,] 10.978 13.646
[48,] 10.178 14.629
[49,] 11.709 15.685
[50,] 12.784 10.509