class probnum.problems.QuadratureProblem(fun, measure, solution)

Bases: object

Numerical computation of an integral.

Compute the integral

$\int_\Omega f(x) \, \text{d} \mu(x)$

for a function $$f: \Omega \rightarrow \mathbb{R}$$ w.r.t. the measure $$\mu$$.

Parameters:
• fun (Callable[[np.ndarray], np.ndarray]) – Function to be integrated. It needs to accept a shape=(n_eval, input_dim) np.ndarray and return a shape=(n_eval,) np.ndarray.

• measure (quad.integration_measures.IntegrationMeasure) – The integration measure.

• solution (Optional[Union[float, np.ndarray, randvars.RandomVariable]]) – Analytic value of the integral or precise numerical solution. Used for testing and benchmarking.

Examples

>>> import numpy as np
>>> from probnum.quad.integration_measures import LebesgueMeasure
>>>
>>> def fun(x):
...     return np.linalg.norm(x, axis=1)**2
>>>
>>> measure1d = LebesgueMeasure(domain=(0, 1), input_dim=1)
>>> qp1d = QuadratureProblem(fun, measure=measure1d, solution=1/3)
>>> np.round(qp1d.fun(np.array([[0.2]]))[0], 2)
0.04
>>> measure2d = LebesgueMeasure(domain=(0, 1), input_dim=2)
>>> qp2d = QuadratureProblem(fun, measure=measure2d, solution=None)
>>> np.round(qp2d.fun(np.array([[0.2, 0.2]]))[0], 2)
0.08