\Header{mvrnorm}{Simulate from a Multivariate Normal Distribution}
\keyword{distribution}{mvrnorm}
\keyword{multivariate}{mvrnorm}
\begin{Description}\relax
Produces one or more samples from the specified
multivariate normal distribution.
\end{Description}
\begin{Usage}
\begin{verbatim}
mvrnorm(n = 1, mu, Sigma, tol = 1e-6, empirical = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{n}] the number of samples required.

\item[\code{mu}] a vector giving the means of the variables.

\item[\code{Sigma}] a positive-definite symmetric matrix specifying the covariance matrix
of the variables.

\item[\code{tol}] tolerance (relative to largest variance) for numerical lack of
positive-definiteness in \code{Sigma}.

\item[\code{empirical}] logical. If true, mu and Sigma specify the empirical not population
mean and covariance matrix.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The matrix decomposition is done via \code{eigen}; although a Choleski
decomposition might be faster, the eigendecomposition is
stabler.
\end{Details}
\begin{Value}
If \code{n = 1} a vector of the same length as \code{mu}, otherwise an
\code{n} by \code{length(mu)} matrix with one sample in each row.
\end{Value}
\begin{Section}{Side Effects}
Causes creation of the dataset \code{.Random.seed} if it does
not already exist, otherwise its value is updated.
\end{Section}
\begin{References}\relax
B. D. Ripley (1987)
\emph{Stochastic Simulation.}
Wiley. Page 98.
\end{References}
\begin{SeeAlso}\relax
\code{\Link{rnorm}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
Sigma <- matrix(c(10,3,3,2),2,2)
Sigma
var(mvrnorm(n=1000, rep(0, 2), Sigma))
var(mvrnorm(n=1000, rep(0, 2), Sigma, empirical = TRUE))
\end{ExampleCode}
\end{Examples}

