pub struct MeasureIntegral;Expand description
Numerical Lebesgue integration using midpoint-rule quadrature.
For a function f: ℝⁿ → ℝ on a box domain, the integral is approximated
by subdividing each dimension into n_pts sub-intervals.
Implementations§
Source§impl MeasureIntegral
impl MeasureIntegral
Sourcepub fn integrate_1d(f: &dyn Fn(f64) -> f64, a: f64, b: f64, n: usize) -> f64
pub fn integrate_1d(f: &dyn Fn(f64) -> f64, a: f64, b: f64, n: usize) -> f64
Integrate f over a 1-D interval [a, b] using n midpoint sub-intervals.
Sourcepub fn integrate_2d(
f: &dyn Fn(f64, f64) -> f64,
a: f64,
b: f64,
c: f64,
d: f64,
n: usize,
) -> f64
pub fn integrate_2d( f: &dyn Fn(f64, f64) -> f64, a: f64, b: f64, c: f64, d: f64, n: usize, ) -> f64
Integrate f over a 2-D rectangle using n × n midpoint sub-intervals.
Sourcepub fn integrate_nd(
f: &dyn Fn(&[f64]) -> f64,
lower: &[f64],
upper: &[f64],
n_pts: usize,
) -> f64
pub fn integrate_nd( f: &dyn Fn(&[f64]) -> f64, lower: &[f64], upper: &[f64], n_pts: usize, ) -> f64
Integrate f over an n-D box using midpoint quadrature.
The box is given as lower and upper vectors; n_pts sub-intervals
per dimension. This has exponential cost in the dimension.
Sourcepub fn monte_carlo(
f: &dyn Fn(&[f64]) -> f64,
lower: &[f64],
upper: &[f64],
n_samples: usize,
) -> f64
pub fn monte_carlo( f: &dyn Fn(&[f64]) -> f64, lower: &[f64], upper: &[f64], n_samples: usize, ) -> f64
Monte Carlo integration of f over an n-D box.
Produces an unbiased estimate with standard error O(1/√n).
Sourcepub fn importance_sampling(
f: &dyn Fn(f64) -> f64,
proposal_sample: &dyn Fn() -> f64,
proposal_density: &dyn Fn(f64) -> f64,
n_samples: usize,
) -> f64
pub fn importance_sampling( f: &dyn Fn(f64) -> f64, proposal_sample: &dyn Fn() -> f64, proposal_density: &dyn Fn(f64) -> f64, n_samples: usize, ) -> f64
Importance-sampling Monte Carlo: ∫ f dx = ∫ (f/g) · g dx.
Samples are drawn from the proposal density g (given as CDF inverse)
and the estimate is (1/n) Σ f(xᵢ) / g(xᵢ).
Auto Trait Implementations§
impl Freeze for MeasureIntegral
impl RefUnwindSafe for MeasureIntegral
impl Send for MeasureIntegral
impl Sync for MeasureIntegral
impl Unpin for MeasureIntegral
impl UnsafeUnpin for MeasureIntegral
impl UnwindSafe for MeasureIntegral
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.