QuadratureProblem¶
-
class
probnum.problems.QuadratureProblem(integrand, lower_bd, upper_bd, output_dim=1, solution=None)[source]¶ Bases:
objectNumerical computation of an integral.
Compute the integral
\[\int_\Omega f(x) \, \text{d} \mu(x)\]for a function \(f: \Omega \rightarrow \mathbb{R}\). For the time being, \(\mu\) is the Lebesgue measure. Solved by quadrature rules in
probnum.quad.- Parameters
integrand (
Callable[[ndarray],Union[float,ndarray]]) – Function to be integrated.lower_bd (
Union[Real,ndarray]) – A number or a vector representing the lower bounds of the integrals.upper_bd (
Union[Real,ndarray]) – A number or a vector representing the upper bounds of the integrals.output_dim (
Optional[int]) – Output dimension of the integrand.solution (
Union[float,ndarray,RandomVariable,None]) – Closed form, analytic solution to the problem. Used for testing and benchmarking.
Examples
>>> import numpy as np >>> def integrand(x): ... return np.linalg.norm(x)**2 >>> lower_bd = 0.41 >>> upper_bd = 4.32 >>> qp1d = QuadratureProblem(integrand, lower_bd=lower_bd, upper_bd=upper_bd) >>> np.round(qp1d.integrand(0.2), 2) 0.04 >>> qp1d.lower_bd 0.41 >>> >>> lower_bd = [0., 0.] >>> upper_bd = [1., 1.] >>> qp2d = QuadratureProblem(integrand, lower_bd=lower_bd, upper_bd=upper_bd) >>> qp2d.upper_bd [1.0, 1.0]
Attributes Summary
Attributes Documentation
-
solution: Optional[Union[float, numpy.ndarray, probnum.randvars.RandomVariable]] = None¶