Stan Math Library  2.15.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  namespace math {
17 
18  template <class RNG>
19  inline double
20  uniform_rng(double alpha,
21  double beta,
22  RNG& rng) {
23  using boost::variate_generator;
24  using boost::random::uniform_real_distribution;
25 
26  static const char* function("uniform_rng");
27 
28  check_finite(function, "Lower bound parameter", alpha);
29  check_finite(function, "Upper bound parameter", beta);
30  check_greater(function, "Upper bound parameter", beta, alpha);
31 
32  variate_generator<RNG&, uniform_real_distribution<> >
33  uniform_rng(rng, uniform_real_distribution<>(alpha, beta));
34  return uniform_rng();
35  }
36 
37  }
38 }
39 #endif
void check_finite(const char *function, const char *name, const T_y &y)
Check if y is finite.
void check_greater(const char *function, const char *name, const T_y &y, const T_low &low)
Check if y is strictly greater than low.
double uniform_rng(double alpha, double beta, RNG &rng)
Definition: uniform_rng.hpp:20

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