queens.parameters.random_fields package#
Random fields.
Modules for random fields.
Submodules#
queens.parameters.random_fields.fourier module#
Fourier Random fields class.
- class DimensionMethods1D[source]#
Bases:
object1D FOURIER expansion helper methods.
- static calculate_basis(coordinates: ndarray, basis_dimension: int, number_expansion_terms: int, convex_hull_size: float, covariance: ndarray, index: ndarray) ndarray[source]#
Calculate the fourier basis.
- Parameters:
coordinates – Vector with coordinates of field
basis_dimension – Dimension of the complete Fourier basis (not the latent space)
number_expansion_terms – Number of frequencies
convex_hull_size – Maximum length on the mesh
covariance – Transform of covariance matrix
index – Array indexing valid basis terms in accordance to the truncation threshold
- Returns:
Transformed and truncated fourier basis
- static calculate_covariance(number_expansion_terms: int, corr_length: float, convex_hull_size: float) ndarray[source]#
Calculate discrete fourier transform of the covariance kernel.
Based on the kernel description of the random field, build its covariance matrix using the external geometry and coordinates.
- Parameters:
number_expansion_terms – Number of frequencies
corr_length – Typical length in the field
convex_hull_size – Max distance on the grid
- Returns:
Cosine transform of covariance matrix
- static get_dim(trunc_threshold: int, number_expansion_terms: int) tuple[ndarray, ndarray, int, int][source]#
Calculate dimension of latent space.
- Parameters:
trunc_threshold – Truncation threshold
number_expansion_terms – Number of frequencies in the expansion
- Returns:
Array indexing the covariance values below the truncation limit
Array indexing the basis terms corresponding to valid covariance values
Dimension of the complete Fourier basis up to the truncation threshold
Dimension of the latent space
- class DimensionMethods2D[source]#
Bases:
object2D FOURIER expansion helper methods.
- static calculate_basis(coordinates: ndarray, basis_dimension: int, number_expansion_terms: int, convex_hull_size: float, covariance: ndarray, index: ndarray) ndarray[source]#
Calculate the fourier basis.
- Parameters:
coordinates – Vector with coordinates of field
basis_dimension – Dimension of the complete Fourier basis (not the latent space)
number_expansion_terms – Number of frequencies
convex_hull_size – Maximum length on the mesh
covariance – Transform of covariance matrix
index – Array indexing valid basis terms in accordance to the truncation threshold
- Returns:
Transformed and truncated fourier basis
- static calculate_covariance(number_expansion_terms: int, corr_length: float, convex_hull_size: float) ndarray[source]#
Calculate discrete fourier transform of the covariance kernel.
Based on the kernel description of the random field, build its covariance matrix using the external geometry and coordinates.
- Parameters:
number_expansion_terms – Number of frequencies
corr_length – Typical length in the field
convex_hull_size – Max distance on the grid
- Returns:
Cosine transform of covariance matrix
- static get_dim(trunc_threshold: int, number_expansion_terms: int) tuple[ndarray, ndarray, int, int][source]#
Calculate dimension of latent space.
- Parameters:
trunc_threshold – Truncation threshold
number_expansion_terms – Number of frequencies in the expansion
- Returns:
Array indexing the covariance values below the truncation limit
Array indexing the basis terms corresponding to valid covariance values
Dimension of the complete Fourier basis up to the truncation threshold
Dimension of the latent space
- class DimensionMethods3D[source]#
Bases:
object3D FOURIER expansion helper methods.
- static calculate_basis(coordinates: ndarray, basis_dimension: int, number_expansion_terms: int, convex_hull_size: float, covariance: ndarray, index: ndarray) ndarray[source]#
Calculate the fourier basis.
- Parameters:
coordinates – Vector with coordinates of field
basis_dimension – Dimension of the complete Fourier basis (not the latent space)
number_expansion_terms – Number of frequencies
convex_hull_size – Maximum length on the mesh
covariance – Transform of covariance matrix
index – Array indexing valid basis terms in accordance to the truncation threshold
- Returns:
Transformed and truncated fourier basis
- static calculate_covariance(number_expansion_terms: int, corr_length: float, convex_hull_size: float) ndarray[source]#
Calculate discrete fourier transform of the covariance kernel.
Based on the kernel description of the random field, build its covariance matrix using the external geometry and coordinates.
- Parameters:
number_expansion_terms – Number of frequencies
corr_length – Typical length in the field
convex_hull_size – Max distance on the grid
- Returns:
Cosine transform of covariance matrix
- static get_dim(trunc_threshold: int, number_expansion_terms: int) tuple[ndarray, ndarray, int, int][source]#
Calculate dimension of latent space.
- Parameters:
trunc_threshold – Truncation threshold
number_expansion_terms – Number of frequencies in the expansion
- Returns:
Array indexing the covariance values below the truncation limit
Array indexing the basis terms corresponding to valid covariance values
Dimension of the complete Fourier basis up to the truncation threshold
Dimension of the latent space
- class Fourier(coords: dict, mean: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = 0.0, std: float = 1.0, corr_length: float = 0.3, variability: float = 0.98, trunc_threshold: int = 64)[source]#
Bases:
RandomFieldFOURIER expansion of random fields class.
- mean#
Mean vector at nodes
- std#
Hyperparameter for standard-deviation of random field
- corr_length#
Hyperparameter for the correlation length
- variability#
Explained variance by the fourier decomposition
- trunc_threshold#
Truncation threshold for Fourier series
- basis_dimension#
Dimension of the complete Fourier basis up to the truncation threshold (not the latent space)
- latent_index#
Index array mapping latent space variables to covariance values
- covariance_index#
Array indexing the covariance values below the truncation threshold
- covariance#
Fourier transformed covariance kernel
- basis#
Inverse cosine transformed fourier basis
- coordinates#
Vector of all coordinates in random field
- field_dimension#
Physical dimension of the random field
- number_expansion_terms#
Number of frequencies in all directions
- dimension#
Dimension of latent space
- convex_hull_size#
Euclidean distance between furthest apart coordinates in the field
- draw(num_samples: int) ndarray[source]#
Draw samples from the latent representation of the random field.
- Parameters:
num_samples – Number of draws of latent random samples
- Returns:
Drawn samples
- expanded_representation(samples: ndarray) ndarray[source]#
Expand latent representation of samples.
- Parameters:
samples – Latent representation of samples
- Returns:
Expanded representation of samples
- grad_logpdf(samples: ndarray) ndarray[source]#
Get gradient of joint log-PDF of latent space.
- Parameters:
samples – Samples for evaluating the gradient of the log-PDF
- Returns:
Gradient of the log-PDF
queens.parameters.random_fields.karhunen_loeve module#
Karhunen-Loève Random fields class.
- class KarhunenLoeve(coords: dict, mean: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = 0.0, std: float = 1.0, corr_length: float = 0.3, explained_variance: float | None = None, latent_dimension: int | None = None, cut_off: float = 0.0)[source]#
Bases:
RandomFieldKarhunen Loeve RandomField class.
- nugget_variance#
Nugget variance for the random field (lower bound for diagonal values of the covariance matrix).
- explained_variance#
Explained variance by the eigen decomposition.
- std#
Hyperparameter for standard-deviation of random field
- corr_length#
Hyperparameter for the correlation length
- cut_off#
Lower value limit of covariance matrix entries
- mean#
Mean at coordinates of random field, can be a single constant
- cov_matrix#
Covariance matrix to compute eigendecomposition on
- eigenbasis#
Eigenvectors of covariance matrix, weighted by the eigenvalues
- eigenvalues#
Eigenvalues of covariance matrix
- eigenvectors#
Eigenvectors of covariance matrix
- dimension#
Dimension of the latent space
- calculate_covariance_matrix() None[source]#
Calculate discretized covariance matrix.
Based on the kernel description of the random field, build its covariance matrix using the external geometry and coordinates.
- draw(num_samples: int) ndarray[source]#
Draw samples from the latent representation of the random field.
- Parameters:
num_samples – Number of draws of latent random samples
- Returns:
Drawn samples
- eigendecomp_cov_matrix(latent_dimension: int | None = None) int[source]#
Decompose and then truncate the random field.
According to desired variance fraction that should be covered/explained by the truncation. Also computes the dimension of the latent space if it is not provided.
- Parameters:
latent_dimension – Dimension of the latent space
- Returns:
Dimension of the latent space
- expanded_representation(samples: ndarray) ndarray[source]#
Expand latent representation of samples.
- Parameters:
samples – Latent representation of samples
- Returns:
Expanded representation of samples
- grad_logpdf(samples: ndarray) ndarray[source]#
Get gradient of joint log-PDF of latent space.
- Parameters:
samples – Samples for evaluating the gradient of the log-PDF
- Returns:
Gradient of the log-PDF
queens.parameters.random_fields.piece_wise module#
Piece-wise random fields class.
- class PieceWise(coords: dict, latent_1d_distribution: Continuous | Discrete)[source]#
Bases:
RandomFieldPiece-wise random field class.
The field is constructed at each node or element which is given by the coordinates. Each piece is assumed independently. Equals creating random variables for each point in coords.
- distribution#
Dummy distribution with correct dimension
- latent_1d_distribution#
QUEENS distribution object of latent space variables
- draw(num_samples: int) ndarray[source]#
Draw samples from the latent representation of the random field.
- Parameters:
num_samples – Number of draws of latent random samples
- Returns:
Drawn samples
- expanded_representation(samples: ndarray) ndarray[source]#
Expand latent representation of samples.
- Parameters:
samples – Latent representation of samples
- Returns:
Expanded representation of samples
- grad_logpdf(samples: ndarray) ndarray[source]#
Get gradient of joint log-PDF of latent space.
- Parameters:
samples – Latent space samples
- Returns:
Gradient of the log-PDF of the samples