Module monte_carlo

Module monte_carlo 

Source
Expand description

Monte Carlo Integration

Uses random sampling to estimate integrals, especially useful for high-dimensional integrals that are difficult to compute analytically.

Supports parallel processing for improved performance.

§Examples

use advanced_algorithms::optimization::monte_carlo;

// Estimate integral of x^2 from 0 to 1
let f = |x: &[f64]| x[0] * x[0];
let bounds = vec![(0.0, 1.0)];

let result = monte_carlo::integrate(f, &bounds, 100000).unwrap();
// Should be close to 1/3 ≈ 0.333...
assert!((result.value - 0.333).abs() < 0.01);

Structs§

IntegrationResult
Result of Monte Carlo integration

Functions§

integrate
Performs Monte Carlo integration
integrate_importance_sampling
Monte Carlo integration with importance sampling