class gpr::laplace::SliceSampler¶
Overview¶
Doubling slice sampler over a p-dim continuous parameter, with random-direction Gibbs proposals. More…
#include <SliceSampler.h>
class SliceSampler {
public:
// typedefs
typedef std::function<double(const Eigen::VectorXd&)> LogTarget;
typedef std::function<Eigen::VectorXd(const Eigen::VectorXd&)> AlphaCacheFn;
// construction
SliceSampler(SliceSamplerOptions opts = {});
// methods
bool sample(const Eigen::VectorXd& theta_init, const LogTarget& log_target, const AlphaCacheFn& alpha_fn, SliceSamplerState& out);
};
Detailed Documentation¶
Doubling slice sampler over a p-dim continuous parameter, with random-direction Gibbs proposals.
Typedefs¶
typedef std::function<double(const Eigen::VectorXd&)> LogTarget
Caller-supplied target: returns log p(theta | y) (or any quantity proportional to it on the natural log scale the slice algorithm is invariant under additive constants). Returning a non-finite value (NaN, -inf) is interpreted as “outside support” and treated as below any slice level.
typedef std::function<Eigen::VectorXd(const Eigen::VectorXd&)> AlphaCacheFn
Caller-supplied alpha cache builder: given theta, returns alpha = K(theta)^-1 y. Called once per accepted sample. If null, alpha_cache is left empty.
Methods¶
bool sample(const Eigen::VectorXd& theta_init, const LogTarget& log_target, const AlphaCacheFn& alpha_fn, SliceSamplerState& out)
Draw opts.n_samples + opts.n_burnin samples starting from theta_init. Returns true and fills out.theta_samples / out.alpha_cache on success; returns false and leaves out.valid == false if the initial point has non-finite log-target (no valid starting state).