Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
normal_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_NORMAL_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_NORMAL_RNG_HPP
3 
4 #include <boost/random/normal_distribution.hpp>
5 #include <boost/random/variate_generator.hpp>
13 
14 namespace stan {
15 
16  namespace math {
17 
18  template <class RNG>
19  inline double
20  normal_rng(const double mu,
21  const double sigma,
22  RNG& rng) {
23  using boost::variate_generator;
24  using boost::normal_distribution;
28 
29  static const char* function("stan::math::normal_rng");
30 
31  check_finite(function, "Location parameter", mu);
32  check_not_nan(function, "Location parameter", mu);
33  check_positive(function, "Scale parameter", sigma);
34  check_not_nan(function, "Scale parameter", sigma);
35 
36  variate_generator<RNG&, normal_distribution<> >
37  norm_rng(rng, normal_distribution<>(mu, sigma));
38  return norm_rng();
39  }
40  }
41 }
42 #endif
bool check_not_nan(const char *function, const char *name, const T_y &y)
Return true if y is not NaN.
bool check_positive(const char *function, const char *name, const T_y &y)
Return true if y is positive.
bool check_finite(const char *function, const char *name, const T_y &y)
Return true if y is finite.
double normal_rng(const double mu, const double sigma, RNG &rng)
Definition: normal_rng.hpp:20

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