R_2変量正規分布 のバックアップ(No.1) - アールメカブ

アールメカブ


R_2変量正規分布 のバックアップ(No.1)


_ Baayen p.105 より

library(MASS)
x <- mvrnorm(n = 1000, mu = c(0,0), 
Sigma = cbind(c(1, 0.8),  c(0.8,1)))

# 単変量の場合の density 関数にあたるのが kde2d

persp(kde2d(x[,1], x[,2], n = 50),
     phi = 30, theta = 20, # angle の指定
     d = 10,
     col = "lightblue",
     shade = 0.75, ltheta = -100,
     border = NA,
     expand = 0.5,
     xlab = "X",ylab ="Y", zlab = "density")
mtext("bivariate standard normal", 3, 1)