| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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>
7 #include <stan/math/prim/mat/err/check_ldlt_factor.hpp>
8 #include <stan/math/prim/scal/err/check_size_match.hpp>
9 #include <stan/math/prim/mat/err/check_symmetric.hpp>
10 #include <stan/math/prim/scal/err/check_finite.hpp>
11 #include <stan/math/prim/scal/err/check_not_nan.hpp>
12 #include <stan/math/prim/scal/err/check_positive.hpp>
13 #include <stan/math/prim/mat/fun/multiply.hpp>
14 #include <stan/math/prim/mat/fun/dot_product.hpp>
15 #include <stan/math/prim/mat/fun/subtract.hpp>
16 #include <stan/math/prim/scal/fun/log1p.hpp>
17 #include <stan/math/prim/scal/fun/constants.hpp>
18 #include <stan/math/prim/mat/prob/multi_normal_rng.hpp>
19 #include <stan/math/prim/scal/prob/inv_gamma_rng.hpp>
20 #include <stan/math/prim/scal/meta/include_summand.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
36 using stan::math::check_finite;
37 using stan::math::check_not_nan;
38 using stan::math::check_symmetric;
39 using stan::math::check_positive;
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
check_not_nan.hpp
multiply.hpp
stan::math::sqrt
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:15
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:63
check_size_match.hpp
check_positive.hpp
inv_gamma_rng.hpp
stan::math::check_symmetric
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.
Definition: check_symmetric.hpp:38
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:33
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:68
dot_product.hpp
stan::math::multi_student_t_rng
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)
Definition: multi_student_t_rng.hpp:30
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
log1p.hpp
subtract.hpp
stan::math::multi_normal_rng
Eigen::VectorXd multi_normal_rng(const Eigen::Matrix< double, Dynamic, 1 > &mu, const Eigen::Matrix< double, Dynamic, Dynamic > &S, RNG &rng)
Definition: multi_normal_rng.hpp:25

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