Stan Math Library  2.6.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
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  using Eigen::Dynamic;
27 
28  template <class RNG>
29  inline Eigen::VectorXd
30  multi_student_t_rng(const double nu,
31  const Eigen::Matrix<double, Dynamic, 1>& mu,
32  const Eigen::Matrix<double, Dynamic, Dynamic>& s,
33  RNG& rng) {
34  static const char* function("stan::math::multi_student_t_rng");
35 
40 
41  check_finite(function, "Location parameter", mu);
42  check_symmetric(function, "Scale parameter", s);
43  check_not_nan(function, "Degrees of freedom parameter", nu);
44  check_positive(function, "Degrees of freedom parameter", nu);
45 
46  Eigen::VectorXd z(s.cols());
47  z.setZero();
48 
49  double w = stan::math::inv_gamma_rng(nu / 2, nu / 2, rng);
50  return mu + std::sqrt(w) * stan::math::multi_normal_rng(z, s, rng);
51  }
52  }
53 }
54 #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.
bool check_symmetric(const char *function, const char *name, const Eigen::Matrix< T_y, Dynamic, Dynamic > &y)
Return true if the specified matrix is symmetric.
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.
Eigen::VectorXd multi_student_t_rng(const double nu, const Eigen::Matrix< double, Dynamic, 1 > &mu, const Eigen::Matrix< double, Dynamic, Dynamic > &s, RNG &rng)
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, Dynamic, 1 > &mu, const Eigen::Matrix< double, Dynamic, Dynamic > &S, RNG &rng)

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