Stan Math Library
2.6.3
probability, sampling & optimization
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerator
Friends
Macros
stan
math
prim
mat
prob
lkj_corr_cholesky_rng.hpp
Go to the documentation of this file.
1
#ifndef STAN_MATH_PRIM_MAT_PROB_LKJ_CORR_CHOLESKY_RNG_HPP
2
#define STAN_MATH_PRIM_MAT_PROB_LKJ_CORR_CHOLESKY_RNG_HPP
3
4
#include <
stan/math/prim/scal/err/check_finite.hpp
>
5
#include <
stan/math/prim/scal/err/check_positive.hpp
>
6
#include <
stan/math/prim/scal/fun/constants.hpp
>
7
#include <
stan/math/prim/scal/prob/beta_rng.hpp
>
8
#include <
stan/math/prim/scal/meta/include_summand.hpp
>
9
#include <
stan/math/prim/mat/fun/factor_cov_matrix.hpp
>
10
#include <
stan/math/prim/mat/fun/factor_U.hpp
>
11
#include <
stan/math/prim/mat/fun/read_corr_L.hpp
>
12
#include <
stan/math/prim/mat/fun/read_corr_matrix.hpp
>
13
#include <
stan/math/prim/mat/fun/read_cov_L.hpp
>
14
#include <
stan/math/prim/mat/fun/read_cov_matrix.hpp
>
15
#include <
stan/math/prim/mat/fun/make_nu.hpp
>
16
#include <
stan/math/prim/scal/fun/identity_constrain.hpp
>
17
#include <
stan/math/prim/scal/fun/identity_free.hpp
>
18
#include <
stan/math/prim/scal/fun/positive_constrain.hpp
>
19
#include <
stan/math/prim/scal/fun/positive_free.hpp
>
20
#include <
stan/math/prim/scal/fun/lb_constrain.hpp
>
21
#include <
stan/math/prim/scal/fun/lb_free.hpp
>
22
#include <
stan/math/prim/scal/fun/ub_constrain.hpp
>
23
#include <
stan/math/prim/scal/fun/ub_free.hpp
>
24
#include <
stan/math/prim/scal/fun/lub_constrain.hpp
>
25
#include <
stan/math/prim/scal/fun/lub_free.hpp
>
26
#include <
stan/math/prim/scal/fun/prob_constrain.hpp
>
27
#include <
stan/math/prim/scal/fun/prob_free.hpp
>
28
#include <
stan/math/prim/scal/fun/corr_constrain.hpp
>
29
#include <
stan/math/prim/scal/fun/corr_free.hpp
>
30
#include <
stan/math/prim/mat/fun/unit_vector_constrain.hpp
>
31
#include <
stan/math/prim/mat/fun/unit_vector_free.hpp
>
32
#include <
stan/math/prim/mat/fun/simplex_constrain.hpp
>
33
#include <
stan/math/prim/mat/fun/simplex_free.hpp
>
34
#include <
stan/math/prim/mat/fun/ordered_constrain.hpp
>
35
#include <
stan/math/prim/mat/fun/ordered_free.hpp
>
36
#include <
stan/math/prim/mat/fun/positive_ordered_constrain.hpp
>
37
#include <
stan/math/prim/mat/fun/positive_ordered_free.hpp
>
38
#include <
stan/math/prim/mat/fun/cholesky_factor_constrain.hpp
>
39
#include <
stan/math/prim/mat/fun/cholesky_factor_free.hpp
>
40
#include <
stan/math/prim/mat/fun/cholesky_corr_constrain.hpp
>
41
#include <
stan/math/prim/mat/fun/cholesky_corr_free.hpp
>
42
#include <
stan/math/prim/mat/fun/corr_matrix_constrain.hpp
>
43
#include <
stan/math/prim/mat/fun/corr_matrix_free.hpp
>
44
#include <
stan/math/prim/mat/fun/cov_matrix_constrain.hpp
>
45
#include <
stan/math/prim/mat/fun/cov_matrix_free.hpp
>
46
#include <
stan/math/prim/mat/fun/cov_matrix_constrain_lkj.hpp
>
47
#include <
stan/math/prim/mat/fun/cov_matrix_free_lkj.hpp
>
48
49
namespace
stan {
50
namespace
math {
51
52
template
<
class
RNG>
53
inline
Eigen::MatrixXd
54
lkj_corr_cholesky_rng
(
const
size_t
K,
55
const
double
eta,
56
RNG& rng) {
57
static
const
char
*
function
(
"stan::math::lkj_corr_cholesky_rng"
);
58
59
using
stan::math::check_positive
;
60
61
check_positive
(
function
,
"Shape parameter"
, eta);
62
63
Eigen::ArrayXd CPCs((K * (K - 1)) / 2);
64
double
alpha = eta + 0.5 * (K - 1);
65
unsigned
int
count = 0;
66
for
(
size_t
i = 0; i < (K - 1); i++) {
67
alpha -= 0.5;
68
for
(
size_t
j = i + 1; j < K; j++) {
69
CPCs(count) = 2.0 *
stan::math::beta_rng
(alpha, alpha, rng) - 1.0;
70
count++;
71
}
72
}
73
return
stan::math::read_corr_L
(CPCs, K);
74
}
75
76
}
77
}
78
#endif
ub_constrain.hpp
factor_U.hpp
stan::math::beta_rng
double beta_rng(const double alpha, const double beta, RNG &rng)
Definition:
beta_rng.hpp:30
cov_matrix_free_lkj.hpp
positive_free.hpp
check_positive.hpp
lb_free.hpp
cov_matrix_free.hpp
corr_matrix_constrain.hpp
cholesky_factor_free.hpp
unit_vector_free.hpp
include_summand.hpp
corr_constrain.hpp
prob_free.hpp
ordered_constrain.hpp
cov_matrix_constrain_lkj.hpp
beta_rng.hpp
read_cov_L.hpp
simplex_free.hpp
cholesky_corr_constrain.hpp
stan::math::check_positive
bool check_positive(const char *function, const char *name, const T_y &y)
Return true if y is positive.
Definition:
check_positive.hpp:68
identity_free.hpp
simplex_constrain.hpp
prob_constrain.hpp
cholesky_factor_constrain.hpp
stan::math::read_corr_L
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > read_corr_L(const Eigen::Array< T, Eigen::Dynamic, 1 > &CPCs, const size_t K)
Return the Cholesky factor of the correlation matrix of the specified dimensionality corresponding to...
Definition:
read_corr_L.hpp:41
stan::math::lkj_corr_cholesky_rng
Eigen::MatrixXd lkj_corr_cholesky_rng(const size_t K, const double eta, RNG &rng)
Definition:
lkj_corr_cholesky_rng.hpp:54
factor_cov_matrix.hpp
ub_free.hpp
cholesky_corr_free.hpp
constants.hpp
check_finite.hpp
cov_matrix_constrain.hpp
identity_constrain.hpp
positive_ordered_constrain.hpp
positive_constrain.hpp
lub_constrain.hpp
read_cov_matrix.hpp
read_corr_matrix.hpp
read_corr_L.hpp
unit_vector_constrain.hpp
lub_free.hpp
positive_ordered_free.hpp
corr_matrix_free.hpp
make_nu.hpp
lb_constrain.hpp
ordered_free.hpp
corr_free.hpp
[
Stan Home Page
]
© 2011–2015, Stan Development Team.