|
Monte Carlo Integration Library 1.0
High-performance Monte Carlo methods for numerical integration and optimization
|
Metropolis-Hastings MCMC integrator for complex domains. More...
#include <MHintegrator.hpp>
Public Types | |
| using | Point = mc::geom::Point< dim > |
| using | Func = std::function< double(const Point &)> |
Public Member Functions | |
| MHMontecarloIntegrator (const mc::domains::IntegrationDomain< dim > &d) | |
| Construct an MH-based integrator for a domain. | |
| double | integrate (const Func &f, int n_samples, const mc::proposals::Proposal< dim > &proposal, std::uint32_t seed) override |
| Compute the integral using MH sampling combined with volume estimation. | |
| void | setConfig (std::size_t burn_in_, std::size_t thinning_, std::size_t n_samples_volume_, double deviation_, Func p_, Point x0_) |
| Configure the MCMC sampler parameters. | |
Public Member Functions inherited from mc::integrators::Integrator< dim > | |
| Integrator (const mc::domains::IntegrationDomain< dim > &d) | |
| Constructs an integrator for a specific domain. | |
| virtual double | integrate (const std::function< double(const mc::geom::Point< dim > &)> &f, int n_samples, const mc::proposals::Proposal< dim > &proposal, std::uint32_t seed)=0 |
| virtual | ~Integrator ()=default |
| Virtual destructor for proper polymorphic cleanup. | |
Additional Inherited Members | |
Protected Member Functions inherited from mc::integrators::Integrator< dim > | |
| std::vector< mc::geom::Point< dim > > | initializeRandomizer (int numbers) |
| Initializes random samples uniformly distributed in the domain. | |
Protected Attributes inherited from mc::integrators::Integrator< dim > | |
| const mc::domains::IntegrationDomain< dim > & | domain |
| Reference to the integration domain. | |
| std::vector< std::mt19937 > | randomizer |
| Per-thread random number generators. | |
Metropolis-Hastings MCMC integrator for complex domains.
| dim | Dimensionality of the integration domain. |
Two-stage integration approach:
Integral: ∫_Ω f(x) dx ≈ V̂_Ω · (1/M) ∑ᵢ f(xᵢ) where xᵢ ~ π(x) ∝ p(x)
This approach is especially effective for:
Definition at line 43 of file MHintegrator.hpp.
| using mc::integrators::MHMontecarloIntegrator< dim >::Func = std::function<double(const Point&)> |
Definition at line 46 of file MHintegrator.hpp.
| using mc::integrators::MHMontecarloIntegrator< dim >::Point = mc::geom::Point<dim> |
Definition at line 45 of file MHintegrator.hpp.
|
explicit |
Construct an MH-based integrator for a domain.
| d | Reference to the integration domain. |
|
override |
Compute the integral using MH sampling combined with volume estimation.
| f | Integrand function: ℝⁿ → ℝ. |
| n_samples | Number of post-burn-in, post-thinning samples to keep. |
| proposal | Unused (MH uses internal sampler). |
| seed | Random seed for reproducibility. |
| std::runtime_error | if setConfig() not called first. |
| std::invalid_argument | if n_samples ≤ 0. |
| std::runtime_error | if all samples yield non-finite f(x). |
| void mc::integrators::MHMontecarloIntegrator< dim >::setConfig | ( | std::size_t | burn_in_, |
| std::size_t | thinning_, | ||
| std::size_t | n_samples_volume_, | ||
| double | deviation_, | ||
| Func | p_, | ||
| Point | x0_ | ||
| ) |
Configure the MCMC sampler parameters.
| burn_in_ | Number of initial samples to discard (warmup). |
| thinning_ | Keep every k-th sample (k=thinning_) for autocorrelation reduction. |
| n_samples_volume_ | Number of samples for volume estimation. |
| deviation_ | Proposal standard deviation (controls MH acceptance rate). |
| p_ | Target density: π(x) ∝ p(x); should be proportional to integrand. |
| x0_ | Initial point in the domain (burn-in starting point). |
| std::invalid_argument | if parameters are invalid (e.g., thinning=0, x0 ∉ Ω). |