Karhunen Loève Expansion for Multi-Dimensional Fields

The Karhunen Loève Expansion expands the stochastic field as follows:

\[A(x, t) = \sum_{n=1}^{\infty} \sum_{k=1}^{\infty}\eta_{nk}(\theta) \sqrt{\lambda_n(x)} f_n(t, x) \sqrt{\mu_{nk}} g_{nk}(x)\]

where \(\eta_{nk}(\theta)\) are uncorrelated standardized normal random variables and \(\lambda_n(x)\) and \(f_n(x, t)\) are the eigenvalues and eigenvectors repsectively of the “quasi” one dimensional covariance function \(C(x, t_1, t_2)\). \(\mu_{nk}\) and \(g_{nk}(x)\) are the eigenvalues and eigenvectors of the derived “one” dimensional covariance function \(H(x_1, x_2)\). Additional details regarding the simulation formula can be found at [56]

KarhunenLoeve2D Class

The KarhunenLoeve2D class is imported using the following command:

>>> from UQpy.stochastic_process.KarhunenLoeveExpansionTwoDimension2D import KarhunenLoeveExpansion

Methods

class KarhunenLoeveExpansion2D(n_samples, correlation_function, time_intervals, thresholds=None, random_state=None, random_variables=None)[source]

A class to simulate two dimensional stochastic fields from a given auto-correlation function based on the Karhunen-Loeve Expansion

Parameters:
  • n_samples (int) – Number of samples of the stochastic field to be simulated. The run() method is automatically called if n_samples is provided. If n_samples is not provided, then the KarhunenLoeveExpansion2D object is created but samples are not generated.

  • correlation_function (ndarray) – The correlation function of the stochastic process of size (n_time_intervals_dim1, n_time_intervals_dim1, n_time_intervals_dim2, n_time_intervals_dim2)

  • time_intervals (Union[ndarray, float]) – The length of time discretizations.

  • thresholds (Union[list, int, None]) – The threshold number of eigenvalues to be used in the expansion for two dimensions.

  • random_state (Union[None, int, RandomState]) – Random seed used to initialize the pseudo-random number generator. Default is None.

  • random_variables – The random variables used to generate the stochastic field.

run(n_samples, random_variables=None)[source]

Execute the random sampling in the KarhunenLoeveExpansion class.

The run() method is the function that performs random sampling in the KarhunenLoeveExpansion2D class. If n_samples is provided when the KarhunenLoeveExpansion2D object is defined, the run() method is automatically called. The user may also call the run() method directly to generate samples. The run`() method of the KarhunenLoeveExpansion2D class can be invoked many times and each time the generated samples are appended to the existing samples.

Parameters:

n_samples – Number of samples of the stochastic process to be simulated. If the run() method is invoked multiple times, the newly generated samples will be appended to the existing samples.

The run() method has no returns, although it creates and/or appends the samples attribute of the KarhunenLoeveExpansion2D class.

Attributes

KarhunenLoeveExpansion2D.samples

Array of generated samples.

Examples