Karhunen Loève Expansion

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

\[A(x) = \sum_{i=1}^N \sqrt{\lambda_i} \theta_i(\omega)f_i(x)\]

where \(\theta_i(\omega)\) are uncorrelated standardized random variables and \(\lambda_i\) and \(f_i(x)\) are the eigenvalues and eigenvectors repsectively of the covariance function \(C(x_1, x_2)\).

KarhunenLoeve Class

The KarhunenLoaeve class is imported using the following command:

>>> from UQpy.stochastic_process.KarhunenLoeveExpansion import KarhunenLoeveExpansion

Methods

class KarhunenLoeveExpansion(n_samples, correlation_function, time_interval, threshold=None, random_state=None, random_variables=None)[source]

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

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

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

  • time_interval (Union[ndarray, float]) – The length of time interval.

  • threshold (Optional[int]) – The threshold number of eigenvalues to be used in the expansion.

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

  • random_variables (Optional[ndarray]) – The random variables used to generate the stochastic process. Default is None.

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 KarhunenLoeveExpansion class. If n_samples is provided when the KarhunenLoeveExpansion 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 KarhunenLoeveExpansion class can be invoked many times and each time the generated samples are appended to the existing samples.

Parameters:

n_samples (int) – 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 KarhunenLoeveExpansion class.

Attributes

KarhunenLoeveExpansion.samples: ndarray

Array of generated samples.

KarhunenLoeveExpansion.xi: ndarray

The independent gaussian random variables used in the expansion.

Examples