rnorm_qinv_l_chol: Sample from multivariate normal distribution

Description Usage Arguments Details Value

View source: R/rnorm_qinv_l_chol.R

Description

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

Usage

1
2
3
4

Arguments

n

number of elements to generate

L

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

l

p by 1 vector

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.