Stan Math Library  2.15.0
reverse mode automatic differentiation
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 
20 #include <boost/random/gamma_distribution.hpp>
21 #include <boost/random/variate_generator.hpp>
22 
23 namespace stan {
24  namespace math {
25 
26  template <class RNG>
27  inline double
28  inv_gamma_rng(double alpha,
29  double beta,
30  RNG& rng) {
31  using boost::variate_generator;
32  using boost::random::gamma_distribution;
33 
34  static const char* function("inv_gamma_rng");
35 
36  check_positive_finite(function, "Shape parameter", alpha);
37  check_positive_finite(function, "Scale parameter", beta);
38 
39  variate_generator<RNG&, gamma_distribution<> >
40  gamma_rng(rng, gamma_distribution<>(alpha, 1 / beta));
41  return 1 / gamma_rng();
42  }
43 
44  }
45 }
46 #endif
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.
double inv_gamma_rng(double alpha, double beta, RNG &rng)
double gamma_rng(double alpha, double beta, RNG &rng)
Definition: gamma_rng.hpp:28

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