pyblp.Integration¶

class
pyblp.
Integration
(specification, size, specification_options=None)¶ Configuration for building integration nodes and weights.
 Parameters
specification (str) –
How to build nodes and weights. One of the following:
'monte_carlo'
 Draw from a pseudorandom standard multivariate normal distribution. Integration weights are1 / size
. Theseed
field ofoptions
can be used to seed the random number generator.'halton'
 Generate nodes according to the Halton. A different prime (starting with 2, 3, 5, etc.) is used for each dimension of integration. To eliminate correlation between dimensions, the first1000
values are by default discarded in each dimension. To further improve performance (particularly in settings with many dimensions), sequences are also by default scrambled with the algorithm of Owen (2017). Thediscard
,scramble
, andseed
fields ofoptions
can be used to configure these default settings.'lhs'
 Generate nodes according to Latin Hypercube Sampling (LHS). Integration weights are1 / size
. Theseed
field ofoptions
can be used to seed the random number generator.'mlhs'
 Generate nodes according to Modified Latin Hypercube Sampling (MLHS) described by Hess, Train, and Polak (2004). Integration weights are1 / size
. Theseed
field ofoptions
can be used to seed the random number generator.'product'
 Generate nodes and weights according to the levelsize
GaussHermite product rule.'nested_product'
 Generate nodes and weights according to the levelsize
nested GaussHermite product rule. Weights can be negative.'grid'
 Generate a sparse grid of nodes and weights according to the levelsize
GaussHermite quadrature rule. Weights can be negative.'nested_grid'
 Generate a sparse grid of nodes and weights according to the levelsize
nested GaussHermite quadrature rule. Weights can be negative.
Best practice for low dimensions is probably to use
'product'
to a relatively high degree of polynomial accuracy. In higher dimensions,'grid'
or'halton'
appears to scale the best. For more information, see Judd and Skrainka (2011) and Conlon and Gortmaker (2020).Sparse grids are constructed in analogously to the Matlab function nwspgr created by Florian Heiss and Viktor Winschel. For more information, see Heiss and Winschel (2008).
size (int) – The number of draws if
specification
is'monte_carlo'
,'halton'
,'lhs'
, or'mlhs'
, and the level of the quadrature rule otherwise.specification_options (dict, optional) –
Options for the integration specification. The
'monte_carlo'
,'halton'
,'lhs'
, and'mlhs'
specifications support the following option:seed : (int)  Passed to
numpy.random.RandomState
to seed the random number generator before building integration nodes. By default, a seed is not passed to the random number generator. For'halton'
draws, this is only relevant ifscramble
isTrue
(which is the default).
The
'halton'
specification supports the following options:discard : (int)  How many values at the beginning of each dimension’s Halton sequence to discard. Discarding values at the start of each dimension’s sequence is the simplest way to eliminate correlation between dimensions. By default, the first
1000
values in each dimension are discarded.scramble : (bool)  Whether to scramble the sequences with the algorithm of Owen (2017). By default, sequences are scrambled.
Examples