Stan Math Library  2.10.0
reverse mode automatic differentiation
multi_student_t_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_PROB_MULTI_STUDENT_T_RNG_HPP
2 #define STAN_MATH_PRIM_MAT_PROB_MULTI_STUDENT_T_RNG_HPP
3 
4 #include <boost/math/special_functions/gamma.hpp>
5 #include <boost/math/special_functions/fpclassify.hpp>
6 #include <boost/random/variate_generator.hpp>
21 #include <cstdlib>
22 
23 namespace stan {
24 
25  namespace math {
26 
27  template <class RNG>
28  inline Eigen::VectorXd
30  const double nu,
31  const Eigen::Matrix<double, Eigen::Dynamic, 1>& mu,
32  const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& s,
33  RNG& rng
34  ) {
35  static const char* function("stan::math::multi_student_t_rng");
36 
41 
42  check_finite(function, "Location parameter", mu);
43  check_symmetric(function, "Scale parameter", s);
44  check_not_nan(function, "Degrees of freedom parameter", nu);
45  check_positive(function, "Degrees of freedom parameter", nu);
46 
47  Eigen::VectorXd z(s.cols());
48  z.setZero();
49 
50  double w = stan::math::inv_gamma_rng(nu / 2, nu / 2, rng);
51  return mu + std::sqrt(w) * stan::math::multi_normal_rng(z, s, rng);
52  }
53  }
54 }
55 #endif
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:15
bool check_not_nan(const char *function, const char *name, const T_y &y)
Return true if y is not NaN.
double inv_gamma_rng(const double alpha, const double beta, RNG &rng)
bool check_positive(const char *function, const char *name, const T_y &y)
Return true if y is positive.
bool check_finite(const char *function, const char *name, const T_y &y)
Return true if y is finite.
Eigen::VectorXd multi_normal_rng(const Eigen::Matrix< double, Eigen::Dynamic, 1 > &mu, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &S, RNG &rng)
bool check_symmetric(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Return true if the specified matrix is symmetric.
Eigen::VectorXd multi_student_t_rng(const double nu, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &mu, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &s, RNG &rng)

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