Expand description
Python bindings for numerical integration (Vegas adaptive Monte Carlo).
Wraps ocas_eval::numeric::Vegas and the integrate_1d
convenience entry point. Python callables are wrapped into Rust closures
so users can integrate arbitrary Python functions.
import ocas
# One-shot helper: integrate x over [0, 1].
r = ocas.integrate_1d(lambda x: x, 0.0, 1.0)
print(r.integral, r.error) # ~0.5, small error
# Multi-dimensional Vegas with explicit control.
v = ocas.Vegas(2, n_samples=20000, iterations=8, seed=1)
r = v.integrate(lambda xs: xs[0] * xs[1])Structs§
- PyIntegrate
Result - Result of a numerical integration: the estimate and its standard error.
- PyVegas
- Adaptive Monte Carlo integrator (Vegas) over the unit hypercube.
Functions§
- integrate_
1d - Numerically integrate a one-dimensional Python callable
fover[a, b].