Stan Math Library  2.15.0
reverse mode automatic differentiation
frechet_rng.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_PROB_FRECHET_RNG_HPP
2 #define STAN_MATH_PRIM_SCAL_PROB_FRECHET_RNG_HPP
3 
17 #include <boost/random/weibull_distribution.hpp>
18 #include <boost/random/variate_generator.hpp>
19 
20 namespace stan {
21  namespace math {
22 
23  template <class RNG>
24  inline double
25  frechet_rng(double alpha,
26  double sigma,
27  RNG& rng) {
28  using boost::variate_generator;
29  using boost::random::weibull_distribution;
30 
31  static const char* function("frechet_rng");
32 
33  check_finite(function, "Shape parameter", alpha);
34  check_positive(function, "Shape parameter", alpha);
35  check_not_nan(function, "Scale parameter", sigma);
36  check_positive(function, "Scale parameter", sigma);
37 
38  variate_generator<RNG&, weibull_distribution<> >
39  weibull_rng(rng, weibull_distribution<>(alpha, 1.0/sigma));
40  return 1.0 / weibull_rng();
41  }
42 
43  }
44 }
45 #endif
void check_finite(const char *function, const char *name, const T_y &y)
Check if y is finite.
double frechet_rng(double alpha, double sigma, RNG &rng)
Definition: frechet_rng.hpp:25
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
double weibull_rng(double alpha, double sigma, RNG &rng)
Return a pseudorandom Weibull variate with given shape and scale using the specified random number ge...
Definition: weibull_rng.hpp:33
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.