View source: R/mvnorm_couplings.R
rmvnorm_reflectionmax | R Documentation |
Sample from reflection-maximal coupling of two multivariate Normal distributions, specified through their means, with the same covariance matrix, specified through its Cholesky factor and inverse of Cholesky factor.
The idea is that a multivariate Normal is drawn around the first mean (mu1), and then reflected with respect to a hyperplane orthogonal to the direction between mu1 and mu2.
For univariate Normal distribution, see rnorm_reflectionmax
.
rmvnorm_reflectionmax(mu1, mu2, Cholesky, Cholesky_inverse)
mu1 |
First mean |
mu2 |
First mean |
Cholesky |
Cholesky factor, e.g. obtained with |
Cholesky_inverse |
Inverse of Cholesky factor, e.g. obtained with |
A list containing 'xy', a matrix with 2 columns (one for each draw), and a boolean indicator 'identical' indicating whether the two draws are identical.
p <- 3 mu1 <- rep(0, p) mu2 <- rep(1, p) Sigma <- diag(0.4, p, p) Sigma[1,2] <- Sigma[2,1] <- 0.2 Sigma_chol <- chol(Sigma) Sigma_chol_inv <- solve(Sigma_chol) rmvnorm_reflectionmax(mu1, mu2, Sigma_chol, Sigma_chol_inv)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.