Monte Carlo Integration Library 1.0
High-performance Monte Carlo methods for numerical integration and optimization
gaussianProposal.hpp
Go to the documentation of this file.
1// gaussianProposal.hpp
16#ifndef MONTECARLO_1_GAUSSIAN_PROPOSAL_HPP
17#define MONTECARLO_1_GAUSSIAN_PROPOSAL_HPP
18
19#include "proposal.hpp"
20#include "../domains/integration_domain.hpp"
21
22#include <array>
23#include <cmath>
24#include <random>
25#include <stdexcept>
26#include <vector>
27
28namespace mc {
29namespace proposals {
30
31template <size_t dim>
32class GaussianProposal : public Proposal<dim>
33{
34public:
36 const std::vector<double>& mean,
37 const std::vector<double>& sigma);
38
39 mc::geom::Point<dim> sample(std::mt19937& rng) const override;
40 double pdf(const mc::geom::Point<dim>& x) const override;
41
42private:
43 const mc::domains::IntegrationDomain<dim>& domain; // kept for consistency / future use
44
45 std::vector<double> mu;
46 std::vector<double> sig;
47 std::vector<double> inv_sig2; // 1/(sigma^2)
48
49 double log_norm_const = 0.0; // log((2pi)^(-d/2) * prod_i (1/sigma_i))
50
51 void init_from_mu_sig_();
52};
53
54} // namespace proposals
55} // namespace mc
56
57#include "gaussianProposal.tpp"
58
59#endif // MONTECARLO_1_GAUSSIAN_PROPOSAL_HPP
Abstract base class for N-dimensional integration domains.
N-dimensional point representation.
Definition geometry.hpp:32
GaussianProposal(const mc::domains::IntegrationDomain< dim > &d, const std::vector< double > &mean, const std::vector< double > &sigma)
double pdf(const mc::geom::Point< dim > &x) const override
Evaluate the proposal probability density function.
mc::geom::Point< dim > sample(std::mt19937 &rng) const override
Draw a random sample from the proposal distribution.
Abstract proposal distribution interface.
Definition proposal.hpp:29
Abstract base for probability distributions used in importance sampling.