.. index:: pair: namespace; gpr::laplace .. _doxid-namespacegpr_1_1laplace: namespace gpr::laplace ====================== .. toctree:: :hidden: struct_gpr_laplace_PsisLaplaceOptions.rst struct_gpr_laplace_PsisLaplaceState.rst struct_gpr_laplace_SliceSamplerOptions.rst struct_gpr_laplace_SliceSamplerState.rst struct_gpr_laplace_SteinVariationalConfig.rst class_gpr_laplace_PsisLaplace.rst class_gpr_laplace_ScopedKernelState.rst class_gpr_laplace_SliceSampler.rst class_gpr_laplace_SteinVariational.rst class_gpr_laplace_TCovSecondOrder.rst Overview ~~~~~~~~ .. ref-code-block:: cpp :class: doxyrest-overview-code-block namespace laplace { // structs struct :ref:`PsisLaplaceOptions`; struct :ref:`PsisLaplaceState`; struct :ref:`SliceSamplerOptions`; struct :ref:`SliceSamplerState`; struct :ref:`SteinVariationalConfig`; // classes class :ref:`PsisLaplace`; class :ref:`ScopedKernelState`; class :ref:`SliceSampler`; class :ref:`SteinVariational`; class :ref:`TCovSecondOrder`; // global functions double :ref:`logGaussianDensity`(const Eigen::VectorXd& delta, const Eigen::MatrixXd& cov_chol); std::vector :ref:`selfNormalisedWeights`(const std::vector& log_w); double :ref:`estimateParetoKHat`(const std::vector& weights_descending, int M_pareto); } // namespace laplace .. _details-namespacegpr_1_1laplace: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Global Functions ---------------- .. index:: pair: function; logGaussianDensity .. _doxid-namespacegpr_1_1laplace_1a239f90c45b7d7708fd9bef87511bc0ca: .. ref-code-block:: cpp :class: doxyrest-title-code-block double logGaussianDensity(const Eigen::VectorXd& delta, const Eigen::MatrixXd& cov_chol) Log-density of N(0, Sigma) at z, given the Cholesky factor L of Sigma (Sigma = L L^T) and the offset (theta - theta_map). Returns -0.5 (theta - theta_map)^T Sigma^{-1} (theta - theta_map) * 0.5 log det Sigma - (p/2) log(2 pi). Computed via two triangular solves on L for the quadratic term and 2 \* sum log diag(L) for the log-det. .. index:: pair: function; selfNormalisedWeights .. _doxid-namespacegpr_1_1laplace_1aae1a915d413ea80b98090f97eb79bf51: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector selfNormalisedWeights(const std::vector& log_w) Self-normalised importance weights. Numerically stable: subtracts max(log_w) before exp to avoid overflow. Returns weights summing to 1. If log_w is empty, returns empty. .. index:: pair: function; estimateParetoKHat .. _doxid-namespacegpr_1_1laplace_1a09c56ab6a3cca3a5070041a15bb7cb73: .. ref-code-block:: cpp :class: doxyrest-title-code-block double estimateParetoKHat(const std::vector& weights_descending, int M_pareto) Hill-style estimator of the Pareto shape k_hat on the upper-tail of the weight distribution. ``weights_descending`` must be sorted high to low (caller responsibility). M_pareto is the number of upper-tail samples to use; Vehtari 2024 recommends M_pareto = min(K/5, 3\*sqrt(K)) but for K = 16 that is 3, which is too few for the production code path and the diagnostic; we use min(K-1, max(K/5, 8)) to keep the diagnostic honest. Returns 0 if M_pareto < 2 or all weights are equal.