SWoodburyMatrix
objectsR/normal-distribution.R
normal-distribution-methods.Rd
Draw samples and compute density functions for the multivariate normal
distribution with an SWoodburyMatrix
object as its covariance matrix.
dwnorm(x, mean, covariance, log = FALSE)
rwnorm(n, mean, covariance)
A numeric vector or matrix.
Optional mean vector; defaults to zero mean.
WoodburyMatrix
object.
Logical indicating whether to return log of density.
Number of samples to return. If n = 1
, returns a vector,
otherwise returns an n
by nrow(W)
matrix.
dwnorm
: Compute the density of the
distribution
rwnorm
: Draw samples from the distribution
library(Matrix)
# Trivial example with diagonal covariance matrices
W <- WoodburyMatrix(Diagonal(10), Diagonal(10))
x <- rwnorm(10, covariance = W)
print(dwnorm(x, covariance = W, log = TRUE))
#> [1] -14.04641 -15.26103 -18.91791 -16.18885 -15.12880 -17.57357 -16.69482
#> [8] -23.39031 -22.60567 -18.80693