Karhunen Loève Expansion
The Karhunen Loève Expansion expands the stochastic process as follows:
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. Therun()
method is automatically called if n_samples is provided. If n_samples is not provided, then theKarhunenLoeveExpansion
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 isNone
.random_variables (
Optional
[ndarray
]) – The random variables used to generate the stochastic process. Default isNone
.
- 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 theKarhunenLoeveExpansion
class. If n_samples is provided when theKarhunenLoeveExpansion
object is defined, therun()
method is automatically called. The user may also call therun()
method directly to generate samples. Therun`()
method of theKarhunenLoeveExpansion
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 therun()
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 thesamples
attribute of theKarhunenLoeveExpansion
class.