Stan Math Library  2.9.0
reverse mode automatic differentiation
pareto_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_PARETO_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_PARETO_RNG_HPP
3 
4 #include <boost/random/exponential_distribution.hpp>
5 #include <boost/random/variate_generator.hpp>
15 
16 
17 namespace stan {
18  namespace math {
19 
20  template <class RNG>
21  inline double
22  pareto_rng(const double y_min,
23  const double alpha,
24  RNG& rng) {
25  using boost::variate_generator;
26  using boost::exponential_distribution;
27 
28  static const char* function("stan::math::pareto_rng");
29 
31 
32  check_positive_finite(function, "Scale parameter", y_min);
33  check_positive_finite(function, "Shape parameter", alpha);
34 
35  variate_generator<RNG&, exponential_distribution<> >
36  exp_rng(rng, exponential_distribution<>(alpha));
37  return y_min * std::exp(exp_rng());
38  }
39  }
40 }
41 #endif
double pareto_rng(const double y_min, const double alpha, RNG &rng)
Definition: pareto_rng.hpp:22
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
bool check_positive_finite(const char *function, const char *name, const T_y &y)
Return true if y is positive and finite.

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