rnorm_qinv_l: Sample from multivariate normal distribution

Description Usage Arguments Details Value

View source: R/rnorm_qinv_l.R

Description

Sample from multivariate normal distribution with mean Q^{-1}l and covariance matrix Q^{-1}.

Usage

1
2
3
4
5
rnorm_qinv_l <- function(
  n,
  Q,
  l,
  L)

Arguments

n

number of elements to generate

Q

p by p precision matrix.

l

p by 1 vector

L

NULL by default. If not null, Q is ignored and assumed to be LL^t.

Details

The algorithm is as follows

1. Cholesky decomposition of Q into LL^t. (This step is skipped if L is passed in).

2. Sample z from rnorm(p). Let y = Lz + l.

3. Solve for x in LL^tx = y and return.

Value

x

An p x 1 vector if n=1 otherwise a n by p matrix


dcbdan/s525 documentation built on May 19, 2019, 10:48 p.m.