Monte Carlo Integration Library 1.0
High-performance Monte Carlo methods for numerical integration and optimization
Public Member Functions | List of all members
mc::estimators::MCMeanEstimator< dim > Class Template Reference

Uniform Monte Carlo mean estimator. More...

#include <MCMeanEstimator.hpp>

Collaboration diagram for mc::estimators::MCMeanEstimator< dim >:

Public Member Functions

MeanEstimate< dimestimate (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.
 

Detailed Description

template<std::size_t dim>
class mc::estimators::MCMeanEstimator< dim >

Uniform Monte Carlo mean estimator.

Template Parameters
dimDimensionality of the space.

Estimates the mean of f over domain Ω by:

  1. Sampling N points uniformly in bounding box
  2. Filtering to points inside Ω: x₁, ..., x_M where M ≤ N
  3. Computing μ̂ = (1/N) ∑ᵢ f(xᵢ) · 𝟙[xᵢ ∈ Ω]
  4. Estimating variance: σ̂² = E[f²] - μ̂²
  5. Standard error: SE = σ̂/√N

The mean (before multiplying by volume) is the empirical average over all N trials (treating out-of-domain points as contributing 0).

Note
Uses parallel sampling with OpenMP for efficiency.

Definition at line 57 of file MCMeanEstimator.hpp.

Member Function Documentation

◆ estimate()

template<std::size_t dim>
MeanEstimate< dim > mc::estimators::MCMeanEstimator< 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.

Parameters
domainThe integration domain.
seedRandom seed for reproducibility.
n_samplesTotal number of sample points to generate.
fFunction to evaluate (only at points inside domain).
Returns
MeanEstimate with mean, stderr, and sample counts.
Exceptions
std::invalid_argumentif n_samples == 0.

Parallel sampling: each thread gets a deterministic RNG stream and samples its portion of n_samples uniformly in the domain's bounding box. Only points inside the domain contribute to the sum.


The documentation for this class was generated from the following file: