Stan Math Library  2.15.0
reverse mode automatic differentiation
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>
12 
13 namespace stan {
14  namespace math {
15 
16  template <class RNG>
17  inline double
18  normal_rng(double mu,
19  double sigma,
20  RNG& rng) {
21  using boost::variate_generator;
22  using boost::normal_distribution;
23 
24  static const char* function("normal_rng");
25 
26  check_finite(function, "Location parameter", mu);
27  check_not_nan(function, "Location parameter", mu);
28  check_positive(function, "Scale parameter", sigma);
29  check_not_nan(function, "Scale parameter", sigma);
30 
31  variate_generator<RNG&, normal_distribution<> >
32  norm_rng(rng, normal_distribution<>(mu, sigma));
33  return norm_rng();
34  }
35 
36  }
37 }
38 #endif
void check_finite(const char *function, const char *name, const T_y &y)
Check if y is finite.
double normal_rng(double mu, double sigma, RNG &rng)
Definition: normal_rng.hpp:18
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.

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