Stan Math Library  2.11.0
reverse mode automatic differentiation
uniform_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_UNIFORM_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_UNIFORM_RNG_HPP
3 
4 #include <boost/random/uniform_real_distribution.hpp>
5 #include <boost/random/variate_generator.hpp>
14 
15 namespace stan {
16 
17  namespace math {
18 
19  template <class RNG>
20  inline double
21  uniform_rng(const double alpha,
22  const double beta,
23  RNG& rng) {
24  using boost::variate_generator;
25  using boost::random::uniform_real_distribution;
26 
27  static const char* function("stan::math::uniform_rng");
28 
31 
32  check_finite(function, "Lower bound parameter", alpha);
33  check_finite(function, "Upper bound parameter", beta);
34  check_greater(function, "Upper bound parameter", beta, alpha);
35 
36  variate_generator<RNG&, uniform_real_distribution<> >
37  uniform_rng(rng, uniform_real_distribution<>(alpha, beta));
38  return uniform_rng();
39  }
40  }
41 }
42 #endif
double uniform_rng(const double alpha, const double beta, RNG &rng)
Definition: uniform_rng.hpp:21
bool check_finite(const char *function, const char *name, const T_y &y)
Return true if y is finite.
bool check_greater(const char *function, const char *name, const T_y &y, const T_low &low)
Return true if y is strictly greater than low.

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