Based on the quadrature routines found in the CompEcon toolbox by Miranda and Fackler.

## References¶

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.

quantecon.quad.qnwcheb(n, a=1, b=1)[source]

Computes multivariate Guass-Checbychev quadrature nodes and weights.

Parameters: n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) A length-d iterable of lower endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions b : scalar or array_like(float) A length-d iterable of upper endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions nodes : np.ndarray(dtype=float) Quadrature nodes weights : np.ndarray(dtype=float) Weights for quadrature nodes

Notes

Based of original function qnwcheb in CompEcon toolbox by Miranda and Fackler

References

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.

quantecon.quad.qnwequi(n, a, b, kind='N', equidist_pp=None, random_state=None)[source]

Generates equidistributed sequences with property that averages value of integrable function evaluated over the sequence converges to the integral as n goes to infinity.

Parameters: n : int Number of sequence points a : scalar or array_like(float) A length-d iterable of lower endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions b : scalar or array_like(float) A length-d iterable of upper endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions kind : string, optional(default=”N”) One of the following: N - Neiderreiter (default) W - Weyl H - Haber R - pseudo Random equidist_pp : array_like, optional(default=None) TODO: I don’t know what this does random_state : int or np.random.RandomState, optional Random seed (integer) or np.random.RandomState instance to set the initial state of the random number generator for reproducibility. If None, a randomly initialized RandomState is used. nodes : np.ndarray(dtype=float) Quadrature nodes weights : np.ndarray(dtype=float) Weights for quadrature nodes

Notes

Based of original function qnwequi in CompEcon toolbox by Miranda and Fackler

References

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.

quantecon.quad.qnwlege(n, a, b)[source]

Computes multivariate Guass-Legendre quadrature nodes and weights.

Parameters: n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) A length-d iterable of lower endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions b : scalar or array_like(float) A length-d iterable of upper endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions nodes : np.ndarray(dtype=float) Quadrature nodes weights : np.ndarray(dtype=float) Weights for quadrature nodes

Notes

Based of original function qnwlege in CompEcon toolbox by Miranda and Fackler

References

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.

quantecon.quad.qnwnorm(n, mu=None, sig2=None, usesqrtm=False)[source]

Computes nodes and weights for multivariate normal distribution

Parameters: n : int or array_like(float) A length-d iterable of the number of nodes in each dimension mu : scalar or array_like(float), optional(default=zeros(d)) The means of each dimension of the random variable. If a scalar is given, that constant is repeated d times, where d is the number of dimensions sig2 : array_like(float), optional(default=eye(d)) A d x d array representing the variance-covariance matrix of the multivariate normal distribution. nodes : np.ndarray(dtype=float) Quadrature nodes weights : np.ndarray(dtype=float) Weights for quadrature nodes

Notes

Based of original function qnwnorm in CompEcon toolbox by Miranda and Fackler

References

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.

quantecon.quad.qnwlogn(n, mu=None, sig2=None)[source]

Computes nodes and weights for multivariate lognormal distribution

Parameters: n : int or array_like(float) A length-d iterable of the number of nodes in each dimension mu : scalar or array_like(float), optional(default=zeros(d)) The means of each dimension of the random variable. If a scalar is given, that constant is repeated d times, where d is the number of dimensions sig2 : array_like(float), optional(default=eye(d)) A d x d array representing the variance-covariance matrix of the multivariate normal distribution. nodes : np.ndarray(dtype=float) Quadrature nodes weights : np.ndarray(dtype=float) Weights for quadrature nodes

Notes

Based of original function qnwlogn in CompEcon toolbox by Miranda and Fackler

References

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.

quantecon.quad.qnwsimp(n, a, b)[source]

Computes multivariate Simpson quadrature nodes and weights.

Parameters: n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) A length-d iterable of lower endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions b : scalar or array_like(float) A length-d iterable of upper endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions nodes : np.ndarray(dtype=float) Quadrature nodes weights : np.ndarray(dtype=float) Weights for quadrature nodes

Notes

Based of original function qnwsimp in CompEcon toolbox by Miranda and Fackler

References

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.

quantecon.quad.qnwtrap(n, a, b)[source]

Computes multivariate trapezoid rule quadrature nodes and weights.

Parameters: n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) A length-d iterable of lower endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions b : scalar or array_like(float) A length-d iterable of upper endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions nodes : np.ndarray(dtype=float) Quadrature nodes weights : np.ndarray(dtype=float) Weights for quadrature nodes

Notes

Based of original function qnwtrap in CompEcon toolbox by Miranda and Fackler

References

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.

quantecon.quad.qnwunif(n, a, b)[source]

Computes quadrature nodes and weights for multivariate uniform distribution

Parameters: n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) A length-d iterable of lower endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions b : scalar or array_like(float) A length-d iterable of upper endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions nodes : np.ndarray(dtype=float) Quadrature nodes weights : np.ndarray(dtype=float) Weights for quadrature nodes

Notes

Based of original function qnwunif in CompEcon toolbox by Miranda and Fackler

References

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.

quantecon.quad.quadrect(f, n, a, b, kind='lege', *args, **kwargs)[source]

Integrate the d-dimensional function f on a rectangle with lower and upper bound for dimension i defined by a[i] and b[i], respectively; using n[i] points.

Parameters: f : function The function to integrate over. This should be a function that accepts as its first argument a matrix representing points along each dimension (each dimension is a column). Other arguments that need to be passed to the function are caught by *args and **kwargs n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) A length-d iterable of lower endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions b : scalar or array_like(float) A length-d iterable of upper endpoints. If a scalar is given, that constant is repeated d times, where d is the number of dimensions kind : string, optional(default=’lege’) Specifies which type of integration to perform. Valid values are: lege - Gauss-Legendre cheb - Gauss-Chebyshev trap - trapezoid rule simp - Simpson rule N - Neiderreiter equidistributed sequence W - Weyl equidistributed sequence H - Haber equidistributed sequence R - Monte Carlo *args, **kwargs : Other arguments passed to the function f out : scalar (float) The value of the integral on the region [a, b]

Notes

Based of original function quadrect in CompEcon toolbox by Miranda and Fackler

References

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.

quantecon.quad.qnwbeta(n, a=1.0, b=1.0)[source]

Computes nodes and weights for beta distribution

Parameters: n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float), optional(default=1.0) A length-d b : array_like(float), optional(default=1.0) A d x d array representing the variance-covariance matrix of the multivariate normal distribution. nodes : np.ndarray(dtype=float) Quadrature nodes weights : np.ndarray(dtype=float) Weights for quadrature nodes

Notes

Based of original function qnwbeta in CompEcon toolbox by Miranda and Fackler

References

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.

quantecon.quad.qnwgamma(n, a=1.0, b=1.0, tol=3e-14)[source]

Computes nodes and weights for gamma distribution

Parameters: n : int or array_like(float) A length-d iterable of the number of nodes in each dimension a : scalar or array_like(float) Shape parameter of the gamma distribution parameter. Must be positive b : scalar or array_like(float) Scale parameter of the gamma distribution parameter. Must be positive tol : scalar or array_like(float) Tolerance parameter for newton iterations for each node nodes : np.ndarray(dtype=float) Quadrature nodes weights : np.ndarray(dtype=float) Weights for quadrature nodes

Notes

Based of original function qnwgamma in CompEcon toolbox by Miranda and Fackler

References

Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.