quad

xitorch.integrate.quad(fcn: Union[Callable[[], torch.Tensor], Callable[[], Sequence[torch.Tensor]]], xl: Union[float, int, torch.Tensor], xu: Union[float, int, torch.Tensor], params: Sequence[Any] = [], bck_options: Mapping[str, Any] = {}, method: Optional[Union[str, Callable]] = None, **fwd_options) → Union[torch.Tensor, Sequence[torch.Tensor]][source]

Calculate the quadrature:

\[y = \int_{x_l}^{x_u} f(x, \theta)\ \mathrm{d}x\]
Parameters
  • fcn (callable) – The function to be integrated. Its output must be a tensor with shape (*nout) or list of tensors.

  • xl (float, int or 1-element torch.Tensor) – The lower bound of the integration.

  • xu (float, int or 1-element torch.Tensor) – The upper bound of the integration.

  • params (list) – Sequence of any other parameters for the function fcn.

  • bck_options (dict) – Options for the backward quadrature method.

  • method (str or callable or None) – Quadrature method. If None, it will choose "leggauss".

  • **fwd_options – Method-specific options (see method section).

Returns

The quadrature results with shape (*nout) or list of tensors.

Return type

torch.tensor or a list of tensors

method="leggauss"
quad(..., method="leggauss", *, n=100)

Performing 1D integration using Legendre-Gaussian quadrature

Keyword Arguments

n (int) – The number of integration points.