Simulation¶
-
simulation.KL_1DNys(N, M, a, b, Cov, quad='EOLE')¶ Karhunen-Loeve in 1-Dimension using Nystrom method.
- Parameters
N (int) – Order of the Karhunen-Loeve expansion.
M (int) – number of quadrature intervals . \(N \leq M\)
a,b (float) – domain of simulation, \(X_t\) for \(t\) in \([a,b]\)
Cov (func) – The covariance function, a bivariate function
quad (str) – Quadrature used.”EOLE” for the EOLE method and “gaussleg” to use gauss-legendre quadrature.
- Raises
ValueError – Order of expansion N must be less than number of quadrature points
TypeError – Cov must be a callable, bivariate function.
ValueError – Only ‘EOLE’ and ‘gaussleg’ quadrature is supported so far
- Returns
\(X\) 1-D array of the random field of shape (M,)
- Return type
numpy.ndarray
- Returns
\(\phi\) 2-D arrray whose columns are the eigenfunctions. Shape (M,N)
- Return type
numpy.ndarray
- Returns
\(L\) 1-D array of the eigenvalues of shape (M,)
- Return type
numpy.ndarray
-
simulation.KL_2DNys(N, n, m, lims, Cov, quad='EOLE')¶ Solver using the Nystrom method for finding the Karhunen-Loeve expansion
- Parameters
N (int) – Order of the Karhunen-Loeve expansion.
n (int) – n is the number of gridpoints along x direction respectively.
m (int) – m is the number of gridpoints along y direction respectively.
lims (list) – simulation domain is [a,b] x [c,d]
Cov (func) – The covariance function, a bivariate function
quad (str, optional) – The quadrature method used. “EOLE” for the EOLE method and “gaussleg” for Gauss-Legendre.
- Raises
ValueError – Order of expansion N must be less than number of quadrature points
TypeError – Cov must be a callable, bivariate function.
ValueError – Only ‘EOLE’ and ‘gaussleg’ quadrature are supported so far.
- Returns
\(X\) array of shape (n,m), the RF simulation
- Return type
numpy.ndarray
- Returns
\(\phi\) An array holding eigenvectors discretised KL system of (n*m, N)
- Return type
numpy.ndarray
- Returns
\(L\) 1-D array of the eigenvalues of shape (n*m,)
- Return type
numpy.ndarray
-
simulation.circ_embed1D(g, a, b, Cov)¶ The Circulant embedding method in 1-Dimension
- Parameters
g (int) – exponent of the sample size \(N = 2^g\)
a (float) – left end point of domain.
b (float) – right end point of domain.
Cov (func) – A stationary covariance function of one argument.
- Raises
ValueError – Could not find a positive definite embedding. Consider the KL method.
- Returns
\(X\): 1-D array of the random field of shape (N,)
- Return type
numpy.ndarray
-
simulation.circ_embed2D(n, m, lims, Cov)¶ To simulate a 2-D stationary Gaussian field with the circulant embedding method in two dimensions.
- Parameters
n (int) – number of grid points in the x-direction.
m (int) – number of grid points in the y-direction.
lims (numpy.ndarray) – A 4-d vector containing end points of rectangular domain.
Cov (func) – Covariance function of the Gaussian process, a bivariate function
- Raises
TypeError – Cov must be a bivariate function
ValueError – Could not find a postive definite circulant embedding: Consider the KL method.
- Returns
field1: The first field outputed, real part from the embedding method.
- Return type
numpy.ndarray
- Returns
field2: The second field outputed, imaginary part from the emedding method.
- Return type
numpy.ndarray