1#ifndef STAN_MATH_MIX_FUNCTOR_LAPLACE_BASE_RNG_HPP
2#define STAN_MATH_MIX_FUNCTOR_LAPLACE_BASE_RNG_HPP
34template <
typename LLFunc,
typename LLArgs,
typename CovarFun,
35 typename CovarArgs,
bool InitTheta,
typename RNG,
36 require_t<is_all_arithmetic_scalar<CovarArgs, LLArgs>>* =
nullptr>
38 LLFunc&& ll_fun, LLArgs&& ll_args, CovarFun&& covariance_function,
42 ll_fun, std::forward<LLArgs>(ll_args),
43 std::forward<CovarFun>(covariance_function),
44 to_ref(std::forward<CovarArgs>(covar_args)), options, msgs);
46 auto&& covariance_train = md_est.covariance;
47 Eigen::VectorXd mean_train = covariance_train * md_est.theta_grad;
48 if (options.solver == 1 || options.solver == 2) {
50 = md_est.L.template triangularView<Eigen::Lower>().solve(
51 md_est.W_r * covariance_train);
52 Eigen::MatrixXd Sigma = covariance_train - V_dec.transpose() * V_dec;
60 * md_est.LU.solve(covariance_train * md_est.W_r))
StdVectorBuilder< true, Eigen::VectorXd, T_loc >::type multi_normal_rng(const T_loc &mu, const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &S, RNG &rng)
Return a multivariate normal random variate with the given location and covariance using the specifie...
Reference for calculations of marginal and its gradients: Margossian et al (2020),...
auto laplace_marginal_density_est(LLFun &&ll_fun, LLTupleArgs &&ll_args, CovarFun &&covariance_function, CovarArgs &&covar_args, const laplace_options< InitTheta > &options, std::ostream *msgs)
For a latent Gaussian model with hyperparameters phi and latent variables theta, and observations y,...
Eigen::VectorXd laplace_base_rng(LLFunc &&ll_fun, LLArgs &&ll_args, CovarFun &&covariance_function, CovarArgs &&covar_args, const laplace_options< InitTheta > &options, RNG &rng, std::ostream *msgs)
In a latent gaussian model,.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...