Stan Math Library
2.9.0
reverse mode automatic differentiation
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
stan
math
prim
scal
prob
gamma_rng.hpp
Go to the documentation of this file.
1
#ifndef STAN_MATH_PRIM_SCAL_PROB_GAMMA_RNG_HPP
2
#define STAN_MATH_PRIM_SCAL_PROB_GAMMA_RNG_HPP
3
4
#include <boost/random/gamma_distribution.hpp>
5
#include <boost/random/variate_generator.hpp>
6
#include <
stan/math/prim/scal/meta/OperandsAndPartials.hpp
>
7
#include <
stan/math/prim/scal/err/check_consistent_sizes.hpp
>
8
#include <
stan/math/prim/scal/err/check_greater_or_equal.hpp
>
9
#include <
stan/math/prim/scal/err/check_less_or_equal.hpp
>
10
#include <
stan/math/prim/scal/err/check_nonnegative.hpp
>
11
#include <
stan/math/prim/scal/err/check_not_nan.hpp
>
12
#include <
stan/math/prim/scal/err/check_positive_finite.hpp
>
13
#include <
stan/math/prim/scal/fun/constants.hpp
>
14
#include <
stan/math/prim/scal/fun/multiply_log.hpp
>
15
#include <
stan/math/prim/scal/fun/value_of.hpp
>
16
#include <
stan/math/prim/scal/fun/gamma_p.hpp
>
17
#include <
stan/math/prim/scal/fun/digamma.hpp
>
18
#include <
stan/math/prim/scal/meta/length.hpp
>
19
#include <
stan/math/prim/scal/meta/is_constant_struct.hpp
>
20
#include <
stan/math/prim/scal/meta/VectorView.hpp
>
21
#include <
stan/math/prim/scal/meta/VectorBuilder.hpp
>
22
#include <
stan/math/prim/scal/meta/partials_return_type.hpp
>
23
#include <
stan/math/prim/scal/meta/return_type.hpp
>
24
#include <
stan/math/prim/scal/meta/include_summand.hpp
>
25
#include <
stan/math/prim/scal/fun/grad_reg_inc_gamma.hpp
>
26
27
namespace
stan
{
28
29
namespace
math {
30
31
template
<
class
RNG>
32
inline
double
33
gamma_rng
(
const
double
alpha,
34
const
double
beta,
35
RNG& rng) {
36
using
boost::variate_generator;
37
using
boost::gamma_distribution;
38
39
static
const
char
*
function
(
"stan::math::gamma_rng"
);
40
41
using
stan::math::check_positive_finite
;
42
43
check_positive_finite
(
function
,
"Shape parameter"
, alpha);
44
check_positive_finite
(
function
,
"Inverse scale parameter"
, beta);
45
46
/*
47
the boost gamma distribution is defined by
48
shape and scale, whereas the stan one is defined
49
by shape and rate
50
*/
51
variate_generator<RNG&, gamma_distribution<> >
52
gamma_rng
(rng, gamma_distribution<>(alpha, 1.0 / beta));
53
return
gamma_rng
();
54
}
55
56
}
57
}
58
59
#endif
check_not_nan.hpp
stan::math::gamma_rng
double gamma_rng(const double alpha, const double beta, RNG &rng)
Definition:
gamma_rng.hpp:33
check_positive_finite.hpp
stan
Definition:
log_sum_exp.hpp:8
digamma.hpp
return_type.hpp
VectorView.hpp
include_summand.hpp
multiply_log.hpp
check_nonnegative.hpp
check_less_or_equal.hpp
OperandsAndPartials.hpp
VectorBuilder.hpp
partials_return_type.hpp
length.hpp
gamma_p.hpp
grad_reg_inc_gamma.hpp
constants.hpp
is_constant_struct.hpp
check_greater_or_equal.hpp
value_of.hpp
check_consistent_sizes.hpp
stan::math::check_positive_finite
bool check_positive_finite(const char *function, const char *name, const T_y &y)
Return true if y is positive and finite.
Definition:
check_positive_finite.hpp:28
[
Stan Home Page
]
© 2011–2015, Stan Development Team.