Skip to main content

Module numeric

Module numeric 

Source
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§

PyIntegrateResult
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 f over [a, b].