Stan Math Library  2.15.0
reverse mode automatic differentiation
exponential_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_EXPONENTIAL_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_EXPONENTIAL_RNG_HPP
3 
14 #include <boost/random/exponential_distribution.hpp>
15 #include <boost/random/variate_generator.hpp>
16 
17 namespace stan {
18  namespace math {
19 
20  template <class RNG>
21  inline double
22  exponential_rng(double beta,
23  RNG& rng) {
24  using boost::variate_generator;
25  using boost::exponential_distribution;
26 
27  static const char* function("exponential_rng");
28 
29  check_positive_finite(function, "Inverse scale parameter", beta);
30 
31  variate_generator<RNG&, exponential_distribution<> >
32  exp_rng(rng, exponential_distribution<>(beta));
33  return exp_rng();
34  }
35 
36  }
37 }
38 #endif
double exponential_rng(double beta, RNG &rng)
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.

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