1#ifndef STAN_MATH_PRIM_PROB_GAUSSIAN_DLM_OBS_RNG_HPP
2#define STAN_MATH_PRIM_PROB_GAUSSIAN_DLM_OBS_RNG_HPP
7#include <boost/random/normal_distribution.hpp>
8#include <boost/random/variate_generator.hpp>
30 const Eigen::VectorXd &mu,
const Eigen::LDLT<Eigen::MatrixXd> &S_ldlt,
32 using boost::normal_distribution;
33 using boost::variate_generator;
36 rng, normal_distribution<>(0, 1));
38 Eigen::VectorXd stddev = S_ldlt.vectorD().array().sqrt().matrix();
39 size_t M = S_ldlt.vectorD().size();
41 for (
int i = 0; i < M; i++) {
46 = mu + (S_ldlt.transpositionsP().transpose() * (S_ldlt.matrixL() * z));
89 const Eigen::MatrixXd &G,
90 const Eigen::MatrixXd &V,
91 const Eigen::MatrixXd &W,
92 const Eigen::VectorXd &m0,
93 const Eigen::MatrixXd &C0,
94 const int T, RNG &rng) {
95 static constexpr const char *function =
"gaussian_dlm_obs_rng";
121 Eigen::LDLT<Eigen::MatrixXd> V_ldlt = V.ldlt();
123 Eigen::LDLT<Eigen::MatrixXd> W_ldlt = W.ldlt();
125 Eigen::LDLT<Eigen::MatrixXd> C0_ldlt = C0.ldlt();
128 Eigen::MatrixXd y(r, T);
129 Eigen::VectorXd theta_t
131 for (
int t = 0; t < T; ++t) {
133 Eigen::VectorXd(G * theta_t), W_ldlt, rng);
135 Eigen::VectorXd(F.transpose() * theta_t), V_ldlt, rng);
141inline Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>
143 const Eigen::VectorXd &V,
const Eigen::MatrixXd &W,
144 const Eigen::VectorXd &m0,
const Eigen::MatrixXd &C0,
145 const int T, RNG &rng) {
void check_symmetric(const char *function, const char *name, const matrix_cl< T > &y)
Check if the matrix_cl is symmetric.
Eigen::MatrixXd gaussian_dlm_obs_rng(const Eigen::MatrixXd &F, const Eigen::MatrixXd &G, const Eigen::MatrixXd &V, const Eigen::MatrixXd &W, const Eigen::VectorXd &m0, const Eigen::MatrixXd &C0, const int T, RNG &rng)
Simulate random draw from Gaussian dynamic linear model (GDLM).
Eigen::VectorXd multi_normal_semidefinite_rng(const Eigen::VectorXd &mu, const Eigen::LDLT< Eigen::MatrixXd > &S_ldlt, RNG &rng)
Return a multivariate normal random variate with the given location and covariance using the specifie...
double std_normal_rng(RNG &rng)
Return a standard Normal random variate using the specified random number generator.
void check_square(const char *function, const char *name, const T_y &y)
Check if the specified matrix is square.
void check_pos_semidefinite(const char *function, const char *name, const EigMat &y)
Check if the specified matrix is positive definite.
void check_finite(const char *function, const char *name, const T_y &y)
Return true if all values in y are finite.
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
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 ...