Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
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 <boost/random/gamma_distribution.hpp>
5 #include <boost/random/variate_generator.hpp>
26 
27 namespace stan {
28 
29  namespace math {
30 
31  template <class RNG>
32  inline double
33  inv_gamma_rng(const double alpha,
34  const double beta,
35  RNG& rng) {
36  using boost::variate_generator;
37  using boost::random::gamma_distribution;
38 
39  static const char* function("stan::math::inv_gamma_rng");
40 
42 
43  check_positive_finite(function, "Shape parameter", alpha);
44  check_positive_finite(function, "Scale parameter", beta);
45 
46  variate_generator<RNG&, gamma_distribution<> >
47  gamma_rng(rng, gamma_distribution<>(alpha, 1 / beta));
48  return 1 / gamma_rng();
49  }
50  }
51 }
52 
53 #endif
double gamma_rng(const double alpha, const double beta, RNG &rng)
Definition: gamma_rng.hpp:33
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–2015, Stan Development Team.