wmpy.integration.rejection.RejectionIntegrator

class RejectionIntegrator(n_samples=None, seed=None)[source]

Bases: object

This class implements an integrator based on rejection sampling. The integral is approximated with its Monte Carlo (MC) estimate.

Default constructor.

Parameters:
  • n_samples (Optional[int]) – sample size of the MC estimate

  • seed (Optional[int]) – the seed number (optional)

Methods

integrate

Computes a convex integral.

integrate_batch

Computes a batch of integrals.

Attributes

DEF_N_SAMPLES

integrate(polytope, integrand, max_iterations=1)[source]

Computes a convex integral.

Parameters:
  • polytope (Polytope) – convex integration bounds

  • polynomial – the integrand

  • max_iterations (int) – maximum number of rejection sampling attempts (default: 1)

Return type:

float

Returns:

The result of the integration as a non-negative scalar value.

integrate_batch(convex_integrals)[source]

Computes a batch of integrals.

Parameters:

convex_integrals (Collection[tuple[Polytope, Polynomial]]) – a collection of bounds/integrand pairs

Return type:

ndarray

Returns:

The result of the batch of integrations as a numpy array.