Learn R Programming

WoodburyMatrix (version 0.0.1)

normal-distribution-methods: Normal distribution methods for SWoodburyMatrix objects

Description

Draw samples and compute density functions for the multivariate normal distribution with an SWoodburyMatrix object as its covariance matrix.

Usage

dwnorm(x, mean, covariance, log = FALSE)

rwnorm(n, mean, covariance)

Arguments

x

A numeric vector or matrix.

mean

Optional mean vector; defaults to zero mean.

covariance

WoodburyMatrix object.

log

Logical indicating whether to return log of density.

n

Number of samples to return. If n = 1, returns a vector, otherwise returns an n by nrow(W) matrix.

Functions

  • dwnorm: Compute the density of the distribution

  • rwnorm: Draw samples from the distribution

See Also

WoodburyMatrix

Examples

Run this code
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))

Run the code above in your browser using DataLab