

mvrnorm(MASS)                                R Documentation

_S_i_m_u_l_a_t_e _f_r_o_m _a _M_u_l_t_i_v_a_r_i_a_t_e _N_o_r_m_a_l _D_i_s_t_r_i_b_u_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n_:

     Produces one or more samples from the specified multi-
     variate normal distribution.

_U_s_a_g_e_:

     mvrnorm(n=1, mu, Sigma, tol = 1e-6)

_A_r_g_u_m_e_n_t_s_:

       n: the number of samples required.

      mu: a vector giving the means of the variables.

   Sigma: a positive-definite symmetric matrix specifying
          the covariance matrix of the variables.

     tol: tolerance (relative to largest variance) for
          numerical lack of positive-definiteness in
          `Sigma'.

_D_e_t_a_i_l_s_:

     The matrix decomposition is done via `eigen'; although
     a Choleski decomposition might be faster, the eigende-
     composition is stabler.  The help for `rnorm' has an
     alternative version using `svd', which seems a strange
     choice for a positive-definite symmetric matrix (and
     has no check for positive-definiteness).  In S-Plus 4.0
     this is replaced by function `rmvnorm'.

_V_a_l_u_e_:

     If `n = 1' a vector of the same length as `mu', other-
     wise an `n' by `length(mu)' matrix with one sample in
     each row.

_S_i_d_e _E_f_f_e_c_t_s_:

     Causes creation of the dataset `.Random.seed' if it
     does not already exist, otherwise its value is updated.

_R_e_f_e_r_e_n_c_e_s_:

     B. D. Ripley (1987) Stochastic Simulation.  Wiley. Page
     98.

_S_e_e _A_l_s_o_:

     `rnorm'

_E_x_a_m_p_l_e_s_:

     Sigma <- matrix(c(10,3,3,2),2,2)
     Sigma

          [,1] [,2]
     [1,]   10    3
     [2,]    3    2

     var(mvrnorm(n=1000, rep(0, 2), Sigma))

              [,1]     [,2]
     [1,] 9.906492 3.030130
     [2,] 3.030130 2.020929

