1#ifndef STAN_MATH_PRIM_PROB_MULTI_NORMAL_CHOLESKY_RNG_HPP
2#define STAN_MATH_PRIM_PROB_MULTI_NORMAL_CHOLESKY_RNG_HPP
10#include <boost/random/normal_distribution.hpp>
11#include <boost/random/variate_generator.hpp>
32template <
typename T_loc,
class RNG>
36 const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& L, RNG& rng) {
37 using boost::normal_distribution;
38 using boost::variate_generator;
40 static constexpr const char* function =
"multi_normal_cholesky_rng";
42 size_t size_mu = mu_vec[0].size();
45 for (
size_t i = 1; i < N; i++) {
47 "Size of one of the vectors of "
48 "the location variable",
50 "Size of the first vector of the "
55 for (
size_t i = 0; i < N; i++) {
60 const auto& L_ref =
to_ref(L);
65 rng, normal_distribution<>(0, 1));
67 for (
size_t n = 0; n < N; ++n) {
68 Eigen::VectorXd z(L.cols());
69 for (
int i = 0; i < L.cols(); i++) {
typename helper::type type
StdVectorBuilder allocates type T1 values to be used as intermediate values.
This class provides a low-cost wrapper for situations where you either need an Eigen Vector or RowVec...
StdVectorBuilder< true, Eigen::VectorXd, T_loc >::type multi_normal_cholesky_rng(const T_loc &mu, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &L, RNG &rng)
Return a multivariate normal random variate with the given location and Cholesky factorization of the...
auto as_column_vector_or_scalar(T &&a)
as_column_vector_or_scalar of a kernel generator expression.
double std_normal_rng(RNG &rng)
Return a standard Normal random variate using the specified random number generator.
int64_t size_mvt(const ScalarT &)
Provides the size of a multivariate argument.
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
void check_finite(const char *function, const char *name, const T_y &y)
Return true if all values in y are finite.
void check_cholesky_factor(const char *function, const char *name, const Mat &y)
Throw an exception if the specified matrix is not a valid Cholesky factor.
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...