Learn R Programming

algebraic.dist (version 0.9.1)

mvn: Construct a multivariate or univariate normal distribution object.

Description

This function constructs an object representing a normal distribution. If the length of the mean vector mu is 1, it creates a univariate normal distribution. Otherwise, it creates a multivariate normal distribution.

Usage

mvn(mu, sigma = diag(length(mu)))

Value

If mu has length 1, it returns a normal object. If mu has length > 1, it returns an mvn object. Both types of objects contain mu

and sigma as their properties.

Arguments

mu

A numeric vector specifying the means of the distribution. If mu has length 1, a univariate normal distribution is created. If mu has length > 1, a multivariate normal distribution is created.

sigma

A numeric matrix specifying the variance-covariance matrix of the distribution. It must be a square matrix with the same number of rows and columns as the length of mu. Default is the identity matrix of size equal to the length of mu.

Examples

Run this code
# Bivariate normal with identity covariance
X <- mvn(mu = c(0, 0))
mean(X)
vcov(X)

# 1D case returns a normal object
is_normal(mvn(mu = 1, sigma = matrix(4)))

Run the code above in your browser using DataLab