chaospy.quadrature.newton_cotes

chaospy.quadrature.newton_cotes(order, domain=(0, 1), growth=False, segments=1)[source]

Generate the abscissas and weights in Newton-Cotes quadrature.

Newton-Cotes quadrature, are a group of formulas for numerical integration based on evaluating the integrand at equally spaced points.

Args:
order (int, numpy.ndarray:):

Quadrature order.

domain (chaospy.Distribution(), ;class:numpy.ndarray):

Either distribution or bounding of interval to integrate over.

growth (bool):

If True sets the growth rule for the quadrature rule to only include orders that enhances nested samples.

segments (int):

Split intervals into N subintervals and create a patched quadrature based on the segmented quadrature. Can not be lower than order. If 0 is provided, default to square root of order. Nested samples only exist when the number of segments are fixed.

Returns:
(numpy.ndarray, numpy.ndarray):
abscissas:

The quadrature points for where to evaluate the model function with abscissas.shape == (len(dist), N) where N is the number of samples.

weights:

The quadrature weights with weights.shape == (N,).

Examples:
>>> abscissas, weights = chaospy.quadrature.newton_cotes(4)
>>> abscissas.round(4)
array([[0.  , 0.25, 0.5 , 0.75, 1.  ]])
>>> weights.round(4)
array([0.0778, 0.3556, 0.1333, 0.3556, 0.0778])
>>> abscissas, weights = chaospy.quadrature.newton_cotes(4, segments=2)
>>> abscissas.round(4)
array([[0.  , 0.25, 0.5 , 0.75, 1.  ]])
>>> weights.round(4)
array([0.0833, 0.3333, 0.1667, 0.3333, 0.0833])