limes 3.1.0
Composable Calculus Expressions for C++20
Loading...
Searching...
No Matches
limes::methods::monte_carlo< T > Struct Template Reference

Monte Carlo integration using random sampling. Error decreases as O(1/sqrt(n)). More...

#include <methods.hpp>

Public Types

using value_type = T
 

Public Member Functions

constexpr monte_carlo (std::size_t n, std::optional< std::size_t > s=std::nullopt) noexcept
 
algorithms::integration_result< T > operator() (std::function< T(T)> const &f, T a, T b) const
 
constexpr monte_carlo with_seed (std::size_t s) const noexcept
 
constexpr monte_carlo with_samples (std::size_t n) const noexcept
 

Public Attributes

std::size_t samples
 
std::optional< std::size_t > seed
 

Detailed Description

template<typename T = double>
struct limes::methods::monte_carlo< T >

Monte Carlo integration using random sampling. Error decreases as O(1/sqrt(n)).

Definition at line 107 of file methods.hpp.

Member Typedef Documentation

◆ value_type

template<typename T = double>
using limes::methods::monte_carlo< T >::value_type = T

Definition at line 108 of file methods.hpp.

Constructor & Destructor Documentation

◆ monte_carlo()

template<typename T = double>
constexpr limes::methods::monte_carlo< T >::monte_carlo ( std::size_t  n,
std::optional< std::size_t >  s = std::nullopt 
)
inlineconstexprnoexcept

Definition at line 113 of file methods.hpp.

Member Function Documentation

◆ operator()()

template<typename T = double>
algorithms::integration_result< T > limes::methods::monte_carlo< T >::operator() ( std::function< T(T)> const &  f,
a,
b 
) const
inline

◆ with_samples()

template<typename T = double>
constexpr monte_carlo limes::methods::monte_carlo< T >::with_samples ( std::size_t  n) const
inlineconstexprnoexcept

Definition at line 152 of file methods.hpp.

References limes::methods::monte_carlo< T >::seed.

◆ with_seed()

template<typename T = double>
constexpr monte_carlo limes::methods::monte_carlo< T >::with_seed ( std::size_t  s) const
inlineconstexprnoexcept

Definition at line 148 of file methods.hpp.

References limes::methods::monte_carlo< T >::samples.

Member Data Documentation

◆ samples

◆ seed


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