Monte Carlo Integration Library 1.0
High-performance Monte Carlo methods for numerical integration and optimization
MCMeanEstimator.hpp
Go to the documentation of this file.
1
11#ifndef MONTECARLO_DGL_MCMEANESTIMATOR_HPP
12#define MONTECARLO_DGL_MCMEANESTIMATOR_HPP
13
14#include <array>
15#include <cstddef>
16#include <cstdint>
17#include <functional>
18#include <random>
19
20namespace mc::estimators {
21
27template <std::size_t dim>
30 double mean = 0.0;
32 double stderr = 0.0;
34 std::size_t n_samples = 0;
36 std::size_t n_inside = 0;
37};
38
56template <std::size_t dim>
58public:
73 std::uint32_t seed,
74 std::size_t n_samples,
75 const std::function<double(const mc::geom::Point<dim>&)>& f) const;
76
77private:
79 mutable std::array<std::uniform_real_distribution<double>, dim> dist{};
80};
81
82} // namespace mc::estimators
83
84#include "MCMeanEstimator.tpp"
85
86#endif // MONTECARLO_DGL_MCMEANESTIMATOR_HPP
Abstract base class for N-dimensional integration domains.
Uniform Monte Carlo mean estimator.
MeanEstimate< dim > estimate(const mc::domains::IntegrationDomain< dim > &domain, std::uint32_t seed, std::size_t n_samples, const std::function< double(const mc::geom::Point< dim > &)> &f) const
Estimate the mean of a function over a domain using uniform sampling.
N-dimensional point representation.
Definition geometry.hpp:32
constexpr int dim
Default dimensionality for integration.
Definition main.cpp:36
Result of Monte Carlo mean estimation.
std::size_t n_samples
Total samples evaluated (both inside and outside domain).
double stderr
Standard error (i.i.d.
double mean
Estimated mean: μ̂ = (1/N) ∑ f(xᵢ) [only domain points].
std::size_t n_inside
Samples that fell inside the domain (used for mean).