chaospy.construct_recurrence_coefficients¶
- chaospy.construct_recurrence_coefficients(order, dist, recurrence_algorithm='stieltjes', rule='clenshaw_curtis', tolerance=1e-10, scaling=3, n_max=5000)[source]¶
Frontend wrapper for constructing three terms recurrence coefficients.
The algorithm for constructing recurrence coefficients can be specified using the
recurrence_algorithm
flag. It accepts the strings:stieltjes
Use the discretized Stieltjes algorithm for iterative estimate each recurrence coefficient using numerical integration. Typically the method known to have the highest convergence rate.
chebyshev
Use modified Chebyshev algorithm to convert raw statistical moments to the recurrence coefficients. A good algorithm for when raw statistical moments are known analytically.
lanczos
Use a known relationship between the Jakobi matrix and a matrix consisting of abscissas and weights from an alternative integration scheme to estimate the recurrence coefficients. Stabilized using ideas by Rutishauser. An alternative method to
stieltjes
.- Args:
- order (int):
The order of the quadrature.
- dist (chaospy.distributions.baseclass.Distribution):
The distribution which density will be used as weight function. Assumed to one-dimensional.
- recurrence_algorithm (str):
Name of the algorithm used to generate abscissas and weights.
- rule (str):
In the case of
lanczos
orstieltjes
, defines the proxy-integration scheme.- 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:
- (typing.List[numpy.ndarray]):
List of recurrence coefficients with shape
(2, order+1)
. The alpha and beta coefficients can found inout[0]
andout[1]
respectively.
- Examples:
>>> distribution = chaospy.Normal(1, 1) >>> coefficients = chaospy.construct_recurrence_coefficients( ... 4, distribution, recurrence_algorithm="stieltjes") >>> coefficients[0].round(3) array([[1., 1., 1., 1., 1.], [1., 1., 2., 3., 4.]]) >>> distribution = chaospy.J(chaospy.Exponential(), chaospy.Uniform()) >>> coefficients = chaospy.construct_recurrence_coefficients( ... [2, 4], distribution, recurrence_algorithm="chebyshev") >>> coefficients[0].round(4) array([[1., 3., 5.], [1., 1., 4.]]) >>> coefficients[1].round(4) array([[0.5 , 0.5 , 0.5 , 0.5 , 0.5 ], [1. , 0.0833, 0.0667, 0.0643, 0.0635]])