| Stan Math Library 2.11.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

multi_normal_cholesky_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_PROB_MULTI_NORMAL_CHOLESKY_RNG_HPP
2 #define STAN_MATH_PRIM_MAT_PROB_MULTI_NORMAL_CHOLESKY_RNG_HPP
3
4 #include <boost/random/normal_distribution.hpp>
5 #include <boost/random/variate_generator.hpp>
6 #include <stan/math/prim/scal/err/check_size_match.hpp>
7 #include <stan/math/prim/scal/err/check_finite.hpp>
8 #include <stan/math/prim/scal/err/check_not_nan.hpp>
9 #include <stan/math/prim/mat/fun/columns_dot_product.hpp>
10 #include <stan/math/prim/mat/fun/columns_dot_self.hpp>
11 #include <stan/math/prim/mat/fun/dot_product.hpp>
12 #include <stan/math/prim/mat/fun/dot_self.hpp>
13 #include <stan/math/prim/mat/fun/log.hpp>
14 #include <stan/math/prim/mat/fun/log_determinant.hpp>
15 #include <stan/math/prim/mat/fun/mdivide_left_spd.hpp>
16 #include <stan/math/prim/mat/fun/mdivide_left_tri_low.hpp>
17 #include <stan/math/prim/mat/fun/multiply.hpp>
18 #include <stan/math/prim/mat/fun/subtract.hpp>
19 #include <stan/math/prim/mat/fun/sum.hpp>
20
21 #include <stan/math/prim/scal/fun/constants.hpp>
22 #include <stan/math/prim/scal/meta/include_summand.hpp>
23
24 namespace stan {
25
26 namespace math {
27 template <class RNG>
28 inline Eigen::VectorXd
29 multi_normal_cholesky_rng(
30 const Eigen::Matrix<double, Eigen::Dynamic, 1>& mu,
31 const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& S,
32 RNG& rng
33 ) {
34 using boost::variate_generator;
35 using boost::normal_distribution;
36
37 static const char* function("stan::math::multi_normal_cholesky_rng");
38
39 using stan::math::check_finite;
40
41 check_finite(function, "Location parameter", mu);
42
43 variate_generator<RNG&, normal_distribution<> >
44 std_normal_rng(rng, normal_distribution<>(0, 1));
45
46 Eigen::VectorXd z(S.cols());
47 for (int i = 0; i < S.cols(); i++)
48 z(i) = std_normal_rng();
49
50 return mu + S * z;
51 }
52 }
53 }
54
55 #endif
check_not_nan.hpp
multiply.hpp
mdivide_left_spd.hpp
log_determinant.hpp
check_size_match.hpp
stan
Definition: log_sum_exp.hpp:8
log.hpp
include_summand.hpp
columns_dot_product.hpp
dot_product.hpp
stan::math::check_finite
bool check_finite(const char *function, const char *name, const T_y &y)
Return true if y is finite.
Definition: check_finite.hpp:62
constants.hpp
check_finite.hpp
sum.hpp
stan::math::multi_normal_cholesky_rng
Eigen::VectorXd multi_normal_cholesky_rng(const Eigen::Matrix< double, Eigen::Dynamic, 1 > &mu, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &S, RNG &rng)
Definition: multi_normal_cholesky_rng.hpp:29
dot_self.hpp
columns_dot_self.hpp
subtract.hpp
mdivide_left_tri_low.hpp

[ Stan Home Page ] © 2011–2016, Stan Development Team.