Stan Math Library  2.11.0
reverse mode automatic differentiation
gumbel_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_GUMBEL_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_GUMBEL_RNG_HPP
3 
15 #include <boost/random/uniform_01.hpp>
16 #include <boost/random/variate_generator.hpp>
17 
18 namespace stan {
19 
20  namespace math {
21 
22  template <class RNG>
23  inline double
24  gumbel_rng(const double mu,
25  const double beta,
26  RNG& rng) {
27  using boost::variate_generator;
28  using boost::uniform_01;
29 
30  static const char* function("stan::math::gumbel_rng");
31 
34 
35 
36  check_finite(function, "Location parameter", mu);
37  check_positive(function, "Scale parameter", beta);
38 
39  variate_generator<RNG&, uniform_01<> >
40  uniform01_rng(rng, uniform_01<>());
41  return mu - beta * std::log(-std::log(uniform01_rng()));
42  }
43  }
44 }
45 #endif
46 
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
double gumbel_rng(const double mu, const double beta, RNG &rng)
Definition: gumbel_rng.hpp:24
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.

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