Learn R Programming

algebraic.dist (version 0.9.1)

affine_transform: Affine transformation of a normal or multivariate normal distribution.

Description

Computes the distribution of \(AX + b\) where \(X \sim MVN(\mu, \Sigma)\). The result is \(MVN(A\mu + b, A \Sigma A^T)\).

Usage

affine_transform(x, A, b = NULL)

Value

A normal or mvn distribution.

Arguments

x

A normal or mvn distribution object.

A

A numeric matrix (or scalar for univariate).

b

An optional numeric vector (or scalar) for the offset. Default is a zero vector.

Details

For a univariate normal, scalars A and b are promoted to 1x1 matrices and scalar internally. Returns a normal if the result is 1-dimensional.

Examples

Run this code
X <- mvn(c(0, 0), diag(2))
# Project to first component via 1x2 matrix
Y <- affine_transform(X, A = matrix(c(1, 0), 1, 2), b = 5)
mean(Y)

# Scale a univariate normal
Z <- affine_transform(normal(0, 1), A = 3, b = 2)
mean(Z)
vcov(Z)

Run the code above in your browser using DataLab