multiNormal: Generate n, k-dimension pseudo random numbers from normal...

View source: R/multiNormal.R

multiNormalR Documentation

Generate n, k-dimension pseudo random numbers from normal distributions with means 'mu' and covariance matrix 'cov_matrix'

Description

Generate n, k-dimension pseudo random numbers from normal distributions with means 'mu' and covariance matrix 'cov_matrix'

Usage

multiNormal(
  n = 1,
  cov_matrix = matrix(c(1, 0.5, 0.5, 1), nrow = 2, ncol = 2),
  mu = c(0, 0),
  seed = as.integer(Sys.time())
)

Arguments

n

the number of pseudo random multinormal variant sets to generate. Defaults to 1.

cov_matrix

kxk covariance matrix where k is the number of dimensions. Defaults to a 2x2 matrix with SD of 1 and covariance of 0.5. Note that Covariance matrix must be invertible.

mu

vector of means equal of length k. Defaults to c(0,0).

seed

Seed for pseudo random number generating algorithm. Defaults to a integer generated from the system time

Value

a n x k tibble with each n row corresponding to a set of multi-variant normal observations

Examples

cov_matrix = matrix(c(1,0.9,0.9,1), nrow = 2, ncol = 2)
multiNormal(n=1e4, cov_matrix = cov_matrix,  mu=c(0,0), seed = 122)

donovanquimby/simulationRNG documentation built on March 19, 2022, 12:46 p.m.