1 #ifndef STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__CONTINUOUS__MULTI_GP_CHOLESKY_HPP
2 #define STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__CONTINUOUS__MULTI_GP_CHOLESKY_HPP
42 template <
bool propto,
43 typename T_y,
typename T_covar,
typename T_w>
44 typename boost::math::tools::promote_args<T_y,T_covar,T_w>::type
46 const Eigen::Matrix<T_covar,Eigen::Dynamic,Eigen::Dynamic>& L,
47 const Eigen::Matrix<T_w,Eigen::Dynamic,1>& w) {
48 static const char*
function =
"stan::prob::multi_gp_cholesky_log(%1%)";
49 typedef typename boost::math::tools::promote_args<T_y,T_covar,T_w>::type T_lp;
62 y.rows(),
"Size of random variable (rows y)",
63 w.size(),
"Size of kernel scales (w)",
66 y.cols(),
"Size of random variable",
67 L.rows(),
"rows of covariance parameter",
77 lp += NEG_LOG_SQRT_TWO_PI * y.rows() * y.cols();
81 lp -= L.diagonal().array().log().sum() * y.rows();
85 lp += 0.5 * y.cols() *
sum(
log(w));
90 for (
int i = 0; i < y.rows(); i++) {
91 Eigen::Matrix<T_y, Eigen::Dynamic, 1> y_row( y.row(i) );
92 Eigen::Matrix<typename boost::math::tools::promote_args<T_y,T_covar>::type,
103 template <
typename T_y,
typename T_covar,
typename T_w>
105 typename boost::math::tools::promote_args<T_y,T_covar,T_w>::type
107 const Eigen::Matrix<T_covar,Eigen::Dynamic,Eigen::Dynamic>& L,
108 const Eigen::Matrix<T_w,Eigen::Dynamic,1>& w) {
109 return multi_gp_cholesky_log<false>(y,L,w);
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R1, C2 > mdivide_left_tri_low(const Eigen::Matrix< T1, R1, C1 > &A, const Eigen::Matrix< T2, R2, C2 > &b)
fvar< T > dot_self(const Eigen::Matrix< fvar< T >, R, C > &v)
double dot_self(const std::vector< double > &x)
boost::math::tools::promote_args< T_y, T_covar, T_w >::type multi_gp_cholesky_log(const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y, const Eigen::Matrix< T_covar, Eigen::Dynamic, Eigen::Dynamic > &L, const Eigen::Matrix< T_w, Eigen::Dynamic, 1 > &w)
The log of a multivariate Gaussian Process for the given y, w, and a Cholesky factor L of the kernel ...
bool check_size_match(const char *function, T_size1 i, const char *name_i, T_size2 j, const char *name_j, T_result *result)
bool check_finite(const char *function, const T_y &y, const char *name, T_result *result)
Checks if the variable y is finite.
fvar< T > sum(const Eigen::Matrix< fvar< T >, R, C > &m)
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
bool check_positive(const char *function, const T_y &y, const char *name, T_result *result)
Eigen::Matrix< T, Rows, Cols > log(const Eigen::Matrix< T, Rows, Cols > &m)
Return the element-wise logarithm of the matrix or vector.
double sum(std::vector< double > &x)
Eigen::Matrix< fvar< T >, R1, C1 > mdivide_left_tri_low(const Eigen::Matrix< fvar< T >, R1, C1 > &A, const Eigen::Matrix< fvar< T >, R2, C2 > &b)
fvar< T > log(const fvar< T > &x)