1 #ifndef STAN_MATH_PRIM_MAT_PROB_MULTI_NORMAL_RNG_HPP 2 #define STAN_MATH_PRIM_MAT_PROB_MULTI_NORMAL_RNG_HPP 12 #include <boost/random/normal_distribution.hpp> 13 #include <boost/random/variate_generator.hpp> 34 inline Eigen::VectorXd
37 using boost::variate_generator;
38 using boost::normal_distribution;
40 static const char*
function(
"multi_normal_rng");
46 Eigen::LLT<Eigen::MatrixXd> llt_of_S = S.llt();
50 variate_generator<RNG&, normal_distribution<> >
51 std_normal_rng(rng, normal_distribution<>(0, 1));
53 Eigen::VectorXd z(S.cols());
54 for (
int i = 0; i < S.cols(); i++)
55 z(i) = std_normal_rng();
57 return mu + llt_of_S.matrixL() * z;
void check_finite(const char *function, const char *name, const T_y &y)
Check if y is finite.
void check_symmetric(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Check if the specified matrix is symmetric.
Eigen::VectorXd multi_normal_rng(const Eigen::VectorXd &mu, const Eigen::MatrixXd &S, RNG &rng)
Return a pseudo-random vector with a multi-variate normal distribution given the specified location p...
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
void check_pos_definite(const char *function, const char *name, const Eigen::Matrix< T_y, -1, -1 > &y)
Check if the specified square, symmetric matrix is positive definite.