R/conditional_np.R
conditional_np.Rd
This function can be used to obtain the conditional distribution of any Np.
conditional_np(x, mu, Sigma)
x | is a vector with the values that are known. For example, |
---|---|
mu | is the mean vector of the Np. |
Sigma | is the covariance matrix of the Np. |
a list with the mean and covariance matrix of the conditional distribution.
# Consider a N3 normal distribution mu <- c(3, -1, 1) Sigma <- matrix(c(3, -1, 1, -1, 1, 0, 1, 0, 2), ncol=3) # We want the conditional distribution of X2 given X1=2 and X3=0 conditional_np(x=c(2, NA, 0), mu=mu, Sigma=Sigma)#> $mean #> [,1] #> [1,] -0.8 #> #> $sigma #> [,1] #> [1,] 0.6 #># We want the conditional distribution of X1 and X3 given X2=2 conditional_np(x=c(NA, 2, NA), mu=mu, Sigma=Sigma)#> $mean #> [,1] #> [1,] 0 #> [2,] 1 #> #> $sigma #> [,1] [,2] #> [1,] 2 1 #> [2,] 1 2 #>