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

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