ghremite_scipy module¶
Tensor Gauss-Hermite quadrature for integrals against a Gaussian density.
gauss_hermite_grid(dim, points_per_dim)
cached
¶
Return tensor Gauss-Hermite nodes and normalized weights for N(0, I).
The result depends only on dim and points_per_dim, so it is cached.
The returned arrays are shared between calls and must not be modified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
int
|
Number of dimensions. |
required |
points_per_dim
|
int
|
Number of quadrature points in each dimension. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
tuple[np.ndarray, np.ndarray]: |
ndarray
|
|
tuple[ndarray, ndarray]
|
a |
Source code in frac_blp/ghermite_scipy.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
integrate_gaussian(f, dim_f, mu, sigma, points_per_dim=5)
¶
Integrate f(X) for X ~ N(mu, sigma) by tensor Gauss-Hermite quadrature.
Supports up to 5 dimensions. The quadrature weights are positive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Callable[[ndarray], ndarray | float]
|
Function of one
node, a |
required |
dim_f
|
int
|
Dimension of the output of |
required |
mu
|
ndarray
|
Mean of the Gaussian, a |
required |
sigma
|
ndarray
|
Covariance matrix of the Gaussian, a |
required |
points_per_dim
|
int
|
Number of quadrature points in each dimension. Default is 5. |
5
|
Returns:
| Type | Description |
|---|---|
ndarray | float
|
np.ndarray | float: The integral of |
ndarray | float
|
and a |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If |
Source code in frac_blp/ghermite_scipy.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
my_function(x)
¶
Return the sum of squares of the coordinates of a point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
A point, a vector of shape (d,). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The sum of the squared entries of |
Source code in frac_blp/ghermite_scipy.py
106 107 108 109 110 111 112 113 114 115 | |
my_function2(x)
¶
Return the square of the first coordinate and the fourth power of the second.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
A point, a vector of shape (d,) with d >= 2. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The vector |
Source code in frac_blp/ghermite_scipy.py
118 119 120 121 122 123 124 125 126 127 | |