QuadratureProblem¶
- class probnum.problems.QuadratureProblem(integrand, lower_bd, upper_bd, output_dim=1, solution=None)¶
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}\). For the time being, \(\mu\) is the Lebesgue measure. Solved by quadrature rules in
probnum.quad
.- Parameters
integrand (Callable[[np.ndarray], Union[float, np.ndarray]]) – Function to be integrated.
lower_bd (Union[FloatLike, np.ndarray]) – A number or a vector representing the lower bounds of the integrals.
upper_bd (Union[FloatLike, np.ndarray]) – A number or a vector representing the upper bounds of the integrals.
output_dim (Optional[int]) – Output dimension of the integrand.
solution (Optional[Union[float, np.ndarray, randvars.RandomVariable]]) – Closed form, analytic solution to the problem. Used for testing and benchmarking.
- Return type
None
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, np.ndarray, randvars.RandomVariable]] = None¶