This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
Sigma<-matrix(0.6,10,10)+0.4*diag(10)
Sigma
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
## [1,] 1.0 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6
## [2,] 0.6 1.0 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6
## [3,] 0.6 0.6 1.0 0.6 0.6 0.6 0.6 0.6 0.6 0.6
## [4,] 0.6 0.6 0.6 1.0 0.6 0.6 0.6 0.6 0.6 0.6
## [5,] 0.6 0.6 0.6 0.6 1.0 0.6 0.6 0.6 0.6 0.6
## [6,] 0.6 0.6 0.6 0.6 0.6 1.0 0.6 0.6 0.6 0.6
## [7,] 0.6 0.6 0.6 0.6 0.6 0.6 1.0 0.6 0.6 0.6
## [8,] 0.6 0.6 0.6 0.6 0.6 0.6 0.6 1.0 0.6 0.6
## [9,] 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 1.0 0.6
## [10,] 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 1.0
mu=rep(0,10)
mu
## [1] 0 0 0 0 0 0 0 0 0 0
#a
##Mulginal Distribution is multivariate normal
#Mean
mu_12 = mu[1:2]
mu_12
## [1] 0 0
#Covariance
Sigma_12 = Sigma[1:2,1:2]
Sigma_12
## [,1] [,2]
## [1,] 1.0 0.6
## [2,] 0.6 1.0
#b
a=3:10
b=1:2
x_a = rep(1,8)
##Mean
mu[b] + Sigma[b,a]%*%solve(Sigma[a,a])%*%(x_a-mu[a])
## [,1]
## [1,] 0.9230769
## [2,] 0.9230769
#Covariance
Sigma[b,b]-Sigma[b,a]%*%solve(Sigma[a,a])%*%Sigma[a,b]
## [,1] [,2]
## [1,] 0.44615385 0.04615385
## [2,] 0.04615385 0.44615385
#c
a = rep(1,10)
#Mean
t(a)%*%mu
## [,1]
## [1,] 0
##Covariance
t(a)%*%Sigma%*%a
## [,1]
## [1,] 64