1#ifndef STAN_MATH_PRIM_PROB_LKJ_CORR_CHOLESKY_RNG_HPP
2#define STAN_MATH_PRIM_PROB_LKJ_CORR_CHOLESKY_RNG_HPP
14 static constexpr const char* function =
"lkj_corr_cholesky_rng";
17 Eigen::ArrayXd CPCs((K * (K - 1)) / 2);
18 double alpha = eta + 0.5 * (K - 1);
19 unsigned int count = 0;
20 for (
size_t i = 0; i < (K - 1); i++) {
22 for (
size_t j = i + 1; j < K; j++) {
23 CPCs(count) = 2.0 *
beta_rng(alpha, alpha, rng) - 1.0;
VectorBuilder< true, double, T_shape1, T_shape2 >::type beta_rng(const T_shape1 &alpha, const T_shape2 &beta, RNG &rng)
Return a Beta random variate with the supplied success and failure parameters using the given random ...
Eigen::MatrixXd lkj_corr_cholesky_rng(size_t K, double eta, RNG &rng)
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
Eigen::Matrix< value_type_t< T >, Eigen::Dynamic, Eigen::Dynamic > read_corr_L(const T &CPCs, size_t K)
Return the Cholesky factor of the correlation matrix of the specified dimensionality corresponding to...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...