quad¶
Filename: quad.py Authors: Chase Coleman, Spencer Lyon Date: 2014-07-01
Defining various quadrature routines.
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
Returns: nodes : np.ndarray(dtype=float)
Quadrature nodes
weights : np.ndarray(dtype=float)
Weights for quadrature nodes
Notes
Based of original function
qnwchebin CompEcon toolbox by Miranda and FacklerReferences
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)[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
Returns: nodes : np.ndarray(dtype=float)
Quadrature nodes
weights : np.ndarray(dtype=float)
Weights for quadrature nodes
Notes
Based of original function
qnwequiin CompEcon toolbox by Miranda and FacklerReferences
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
Returns: nodes : np.ndarray(dtype=float)
Quadrature nodes
weights : np.ndarray(dtype=float)
Weights for quadrature nodes
Notes
Based of original function
qnwlegein CompEcon toolbox by Miranda and FacklerReferences
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.
Returns: nodes : np.ndarray(dtype=float)
Quadrature nodes
weights : np.ndarray(dtype=float)
Weights for quadrature nodes
Notes
Based of original function
qnwnormin CompEcon toolbox by Miranda and FacklerReferences
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.
Returns: nodes : np.ndarray(dtype=float)
Quadrature nodes
weights : np.ndarray(dtype=float)
Weights for quadrature nodes
Notes
Based of original function
qnwlognin CompEcon toolbox by Miranda and FacklerReferences
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
Returns: nodes : np.ndarray(dtype=float)
Quadrature nodes
weights : np.ndarray(dtype=float)
Weights for quadrature nodes
Notes
Based of original function
qnwsimpin CompEcon toolbox by Miranda and FacklerReferences
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
Returns: nodes : np.ndarray(dtype=float)
Quadrature nodes
weights : np.ndarray(dtype=float)
Weights for quadrature nodes
Notes
Based of original function
qnwtrapin CompEcon toolbox by Miranda and FacklerReferences
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
Returns: nodes : np.ndarray(dtype=float)
Quadrature nodes
weights : np.ndarray(dtype=float)
Weights for quadrature nodes
Notes
Based of original function
qnwunifin CompEcon toolbox by Miranda and FacklerReferences
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
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
Returns: out : scalar (float)
The value of the integral on the region [a, b]
Notes
Based of original function
quadrectin CompEcon toolbox by Miranda and FacklerReferences
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.
Returns: nodes : np.ndarray(dtype=float)
Quadrature nodes
weights : np.ndarray(dtype=float)
Weights for quadrature nodes
Notes
Based of original function
qnwbetain CompEcon toolbox by Miranda and FacklerReferences
Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.
-
quantecon.quad.qnwgamma(n, a=None)[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
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.
Returns: nodes : np.ndarray(dtype=float)
Quadrature nodes
weights : np.ndarray(dtype=float)
Weights for quadrature nodes
Notes
Based of original function
qnwgammain CompEcon toolbox by Miranda and FacklerReferences
Miranda, Mario J, and Paul L Fackler. Applied Computational Economics and Finance, MIT Press, 2002.