legendre_quadrature#

assetlife.quadratures.legendre_quadrature(func, lower_bound, upper_bound, args=(), deg=10)[source]#

Numerical integration of \(f(x)\) over the interval \([a,b]\)

Parameters:
funcCallable

A function of the form y = func(x, a, b, c, …) taking floats or ndarrays as inputs and returning a np.float64 or an ndarray. a, b, c, … are extra arguments that must be passed in the args parameter.

lower_boundfloat or ndarray

The lower bound of the integration.

upper_boundfloat or ndarray

The upper bound of the integration. Can’t be np.inf.

argsany

Extra arguments used in the function call.

degint, default is 10.

Number of sample points and weights for the quadrature

Returns:
outnp.float64 or np.ndarray

The output shape corresponds to a broadcast between a, b and *args.

Notes

The function computes if y = func(x, a, b, c, …) has a compatible shape with lower_bound and upper_bound for x.shape == np.broadcast_shapes(lower_bound, upper_bound). Otherwise, adapt lower_bound, upper_bound or change func implementation.