multi_rnorm: Generate Correlated Normal Random Numbers

Description Usage Arguments Value Examples

View source: R/RcppExports.R

Description

Generate random numbers from a multivariate normal distribution. It can be used to create correlated random numbers.

Usage

1

Arguments

n

The number of samples desired for each variable.

mean

A vector giving the mean of each variable.

sd

A valid covariance matrix.

Value

A matrix with n rows and as many columns as mean values.

Examples

1
2
3
4
mus <- c(0, 3, 5)
sigmas <- matrix(c(1, 0.265, 2.19, 0.265, 0.25, 0.66, 2.19, 0.66, 9), ncol = 3)
mat <- multi_rnorm(100, mus, sigmas)
var(mat)

Example output

          [,1]      [,2]       [,3]
[1,] 1.2432750 0.3537024  2.9159662
[2,] 0.3537024 0.2742255  0.9348927
[3,] 2.9159662 0.9348927 11.9417965

colorednoise documentation built on Aug. 5, 2020, 5:10 p.m.