| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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/random/variate_generator.hpp>
6 #include <stan/math/prim/mat/err/check_ldlt_factor.hpp>
7 #include <stan/math/prim/scal/err/check_size_match.hpp>
8 #include <stan/math/prim/mat/err/check_symmetric.hpp>
9 #include <stan/math/prim/scal/err/check_finite.hpp>
10 #include <stan/math/prim/scal/err/check_not_nan.hpp>
11 #include <stan/math/prim/scal/err/check_positive.hpp>
12 #include <stan/math/prim/mat/fun/multiply.hpp>
13 #include <stan/math/prim/mat/fun/dot_product.hpp>
14 #include <stan/math/prim/mat/fun/subtract.hpp>
15 #include <stan/math/prim/scal/fun/log1p.hpp>
16 #include <stan/math/prim/scal/fun/constants.hpp>
17 #include <stan/math/prim/mat/prob/multi_normal_rng.hpp>
18 #include <stan/math/prim/scal/prob/inv_gamma_rng.hpp>
19 #include <stan/math/prim/scal/meta/include_summand.hpp>
20 #include <cstdlib>
21
22 namespace stan {
23 namespace math {
24
25 template <class RNG>
26 inline Eigen::VectorXd
27 multi_student_t_rng(const double nu,
28 const Eigen::Matrix<double, Eigen::Dynamic, 1>& mu,
29 const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& s,
30 RNG& rng) {
31 static const char* function("multi_student_t_rng");
32
33 check_finite(function, "Location parameter", mu);
34 check_symmetric(function, "Scale parameter", s);
35 check_not_nan(function, "Degrees of freedom parameter", nu);
36 check_positive(function, "Degrees of freedom parameter", nu);
37
38 Eigen::VectorXd z(s.cols());
39 z.setZero();
40
41 double w = inv_gamma_rng(nu / 2, nu / 2, rng);
42 return mu + std::sqrt(w) * multi_normal_rng(z, s, rng);
43 }
44
45 }
46 }
47 #endif
check_not_nan.hpp
multiply.hpp
stan::math::sqrt
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:14
stan::math::check_not_nan
bool check_not_nan(const char *function, const char *name, const T_y &y)
Return true if y is not NaN.
Definition: check_not_nan.hpp:60
check_size_match.hpp
check_positive.hpp
stan
Definition: log_sum_exp.hpp:8
inv_gamma_rng.hpp
check_symmetric.hpp
include_summand.hpp
check_ldlt_factor.hpp
stan::math::inv_gamma_rng
double inv_gamma_rng(const double alpha, const double beta, RNG &rng)
Definition: inv_gamma_rng.hpp:29
multi_normal_rng.hpp
stan::math::check_positive
bool check_positive(const char *function, const char *name, const T_y &y)
Return true if y is positive.
Definition: check_positive.hpp:66
dot_product.hpp
stan::math::multi_normal_rng
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...
Definition: multi_normal_rng.hpp:35
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:60
constants.hpp
check_finite.hpp
log1p.hpp
stan::math::check_symmetric
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.
Definition: check_symmetric.hpp:36
subtract.hpp
stan::math::multi_student_t_rng
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)
Definition: multi_student_t_rng.hpp:27

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