Stan Math Library: stan/math/prim/scal/prob/inv_gamma_rng.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

inv_gamma_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_INV_GAMMA_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_INV_GAMMA_RNG_HPP
3
4 #include <stan/math/prim/scal/err/check_consistent_sizes.hpp>
5 #include <stan/math/prim/scal/err/check_greater_or_equal.hpp>
6 #include <stan/math/prim/scal/err/check_less_or_equal.hpp>
7 #include <stan/math/prim/scal/err/check_nonnegative.hpp>
8 #include <stan/math/prim/scal/err/check_not_nan.hpp>
9 #include <stan/math/prim/scal/err/check_positive_finite.hpp>
10 #include <stan/math/prim/scal/fun/constants.hpp>
11 #include <stan/math/prim/scal/fun/value_of.hpp>
12 #include <stan/math/prim/scal/fun/lgamma.hpp>
13 #include <stan/math/prim/scal/fun/gamma_q.hpp>
14 #include <stan/math/prim/scal/fun/digamma.hpp>
15 #include <stan/math/prim/scal/meta/length.hpp>
16 #include <stan/math/prim/scal/meta/VectorView.hpp>
17 #include <stan/math/prim/scal/meta/VectorBuilder.hpp>
18 #include <stan/math/prim/scal/meta/return_type.hpp>
19 #include <stan/math/prim/scal/fun/grad_reg_inc_gamma.hpp>
20 #include <stan/math/prim/scal/meta/include_summand.hpp>
21 #include <boost/random/gamma_distribution.hpp>
22 #include <boost/random/variate_generator.hpp>
23
24 namespace stan {
25
26 namespace math {
27
28 template <class RNG>
29 inline double
30 inv_gamma_rng(const double alpha,
31 const double beta,
32 RNG& rng) {
33 using boost::variate_generator;
34 using boost::random::gamma_distribution;
35
36 static const char* function("stan::math::inv_gamma_rng");
37
38 using stan::math::check_positive_finite;
39
40 check_positive_finite(function, "Shape parameter", alpha);
41 check_positive_finite(function, "Scale parameter", beta);
42
43 variate_generator<RNG&, gamma_distribution<> >
44 gamma_rng(rng, gamma_distribution<>(alpha, 1 / beta));
45 return 1 / gamma_rng();
46 }
47 }
48 }
49
50 #endif
check_not_nan.hpp
stan::math::gamma_rng
double gamma_rng(const double alpha, const double beta, RNG &rng)
Definition: gamma_rng.hpp:30
lgamma.hpp
check_positive_finite.hpp
stan
Definition: log_sum_exp.hpp:8
digamma.hpp
return_type.hpp
gamma_q.hpp
include_summand.hpp
check_nonnegative.hpp
check_less_or_equal.hpp
stan::math::inv_gamma_rng
double inv_gamma_rng(const double alpha, const double beta, RNG &rng)
Definition: inv_gamma_rng.hpp:30
VectorView.hpp
VectorBuilder.hpp
length.hpp
grad_reg_inc_gamma.hpp
constants.hpp
check_greater_or_equal.hpp
value_of.hpp
check_consistent_sizes.hpp
stan::math::check_positive_finite
bool check_positive_finite(const char *function, const char *name, const T_y &y)
Return true if y is positive and finite.
Definition: check_positive_finite.hpp:28

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