Name : Farhan Dzaffa Arfianto
NIM : 220605110099
Class : C
Institue : Maulana Malik Ibrahim Islamic State University of
Malang
Lecture : Prof. Dr. Suhartono, M.Kom
library(mvtnorm)
library(ggplot2)
library(matlib)
set.seed(123) # Mengatur seed agar hasil acak dapat direproduksi
n <- 1000 # Jumlah sampel
mean <- c(1, 2) # Mean dari distribusi multivariat
cov <- matrix(c(2, 1, 1, 3), nrow = 2) # Matriks kovariansi
sampel <- rmvnorm(n, mean, cov) # Menghasilkan sampel multivariat
ggplot(data.frame(x = sampel[,1], y = sampel[,2]), aes(x, y)) +
geom_point(color = "green") +
labs(x = "Variabel X", y = "Variabel Y") +
ggtitle("Scatter Plot dari Sampel Multivariat (Warna Hijau)")

kumulatif <- pnorm(sampel)
head(kumulatif)
## [,1] [,2]
## [1,] 0.5611093 0.9231075
## [2,] 0.9992333 0.9956855
## [3,] 0.9586480 0.9999996
## [4,] 0.8894019 0.4990066
## [5,] 0.4640736 0.8458089
## [6,] 0.9974584 0.9986932
matriks_korelasi <- cor(sampel)
print(matriks_korelasi)
## [,1] [,2]
## [1,] 1.0000000 0.3512307
## [2,] 0.3512307 1.0000000