rv (version 2.3.4)

rvnorm: Generate Random Variables from a Gaussian (Normal) Sampling Model

Description

Generates a random vector from a Gaussian sampling model.

Usage

rvnorm(n = 1, mean = 0, sd = 1, var = NULL, precision)

Arguments

n

integer: number of variables to generate.

mean

mean, may be a rv

sd

standard deviation; scalar or vector (constant or rv, not matrix)

var

variance, can be given instead of sd. Scalar, vector, or matrix.

precision

inverse variance or variance matrix, may be given instead of sd or var

Value

An rv object of length n times the length of the mean vector.

If mean is a vector, a vector is returned: n refers to how many vectors or scalars are replicated.

References

Kerman, J. and Gelman, A. (2007). Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Statistics and Computing 17:3, 235-244.

See also vignette("rv").

Examples

Run this code
# NOT RUN {
  x <- rvnorm(mean=1:10, sd=1:10) # A vector of length 10.
  Sigma <- diag(1:10)
  y <- rvnorm(mean=1:10, var=Sigma)

# }

Run the code above in your browser using DataCamp Workspace