chaospy.generate_quadrature¶
- chaospy.generate_quadrature(order, dist, rule=None, sparse=False, growth=None, segments=1, recurrence_algorithm='stieltjes', tolerance=1e-10, scaling=3, n_max=5000)[source]¶
Numerical quadrature node and weight generator.
- Args:
- order (int):
The order of the quadrature.
- dist (chaospy.distributions.baseclass.Distribution):
The distribution which density will be used as weight function.
- rule (str, Sequence[str], None):
Rule for generating abscissas and weights. If one name is provided, that rule is applied to all dimensions. If multiple names, each rule is positionally applied to each dimension. If omitted,
clenshaw_curtis
is applied to all continuous dimensions, anddiscrete
to all discrete ones.- sparse (bool):
If True used Smolyak’s sparse grid instead of normal tensor product grid.
- growth (bool, None):
If True sets the growth rule for the quadrature rule to only include orders that enhances nested samples. Defaults to the same value as
sparse
if omitted.- 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.
- recurrence_algorithm (str):
Name of the algorithm used to generate abscissas and weights in case of Gaussian quadrature scheme. If omitted,
analytical
will be tried first, andstieltjes
used if that fails.- tolerance (float):
The allowed relative error in norm between two quadrature orders before method assumes convergence.
- scaling (float):
A multiplier the adaptive order increases with for each step quadrature order is not converged. Use 0 to indicate unit increments.
- n_max (int):
The allowed number of quadrature points to use in approximation.
- Returns:
- (numpy.ndarray, numpy.ndarray):
Abscissas and weights created from full tensor grid rule. Flatten such that
abscissas.shape == (len(dist), len(weights))
.
- Examples:
>>> distribution = chaospy.Iid(chaospy.Normal(0, 1), 2) >>> abscissas, weights = generate_quadrature( ... 1, distribution, rule=("gaussian", "fejer_2")) >>> abscissas.round(3) array([[-1. , -1. , 1. , 1. ], [-4.11, 4.11, -4.11, 4.11]]) >>> weights.round(3) array([0.222, 0.222, 0.222, 0.222])
- See also:
chaospy.quadrature.clenshaw_curtis()
chaospy.quadrature.fejer_1()
chaospy.quadrature.fejer_2()
chaospy.quadrature.gaussian()
chaospy.quadrature.legendre_proxy()
chaospy.quadrature.lobatto()
chaospy.quadrature.kronrod()
chaospy.quadrature.patterson()
chaospy.quadrature.radau()
chaospy.quadrature.leja()
chaospy.quadrature.newton_cotes()
chaospy.quadrature.discrete()
chaospy.quadrature.grid()
chaospy.quadrature.genz_keister_16()
chaospy.quadrature.genz_keister_18()
chaospy.quadrature.genz_keister_22()
chaospy.quadrature.genz_keister_24()