Spectral Representation Method
The Spectral Representation Method (SRM) expands the stochastic process in a Fourier-type expansion of cosines. The
version of the SRM implemented in UQpy
uses a summation of cosines with random phase angles as:
where \(S(\omega_i)\) is the discretized power spectrum at frequency \(\omega_i\), \(\Delta\omega\) is the frequency discretization, and \(\phi_i\) are random phase angles uniformly distributed in \([0, 2\pi]\). For computational efficiency, the SRM is implemented using the Fast Fourier Transform (FFT).
SpectralRepresentation Class
The SpectralRepresentation
class is imported using the following command:
>>> from UQpy.stochastic_process.SpectralRepresentation import SpectralRepresentation
Methods
- class SpectralRepresentation(n_samples, power_spectrum, time_interval, frequency_interval, n_time_intervals, n_frequency_intervals, random_state=None)[source]
A class to simulate stochastic processes from a given power spectrum density using the Spectral Representation Method. This class can simulate uni-variate, multi-variate, and multi-dimensional stochastic processes. The class uses Singular Value Decomposition, as opposed to Cholesky Decomposition, to ensure robust, near-positive definite multi-dimensional power spectra.
- 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 theSpectralRepresentation
object is created but samples are not generated.power_spectrum (
Union
[list
,ndarray
,float
]) –The discretized power spectrum.
For uni-variate, one-dimensional processes power_spectrum will be
list
ornumpy.ndarray
of length n_frequency_intervals.For multi-variate, one-dimensional processes, power_spectrum will be a
list
ornumpy.ndarray
of size(n_of_variables, n_variables, n_frequency_intervals)
.For uni-variate, multi-dimensional processes, power_spectrum will be a
list
ornumpy.ndarray
of size(n_frequency_intervals[0], ..., n_frequency_intervals[n_dimensions-1])
For multi-variate, multi-dimensional processes, power_spectrum will be a
list
ornumpy.ndarray
of size(n_variables, n_variables, n_frequency_intervals[0],...,n_frequency_intervals[n_dimensions-1])
.
time_interval (
Union
[list
,ndarray
,float
]) – Length of time discretizations (\(\Delta t\)) for each dimension of size n_dimensions.frequency_interval (
Union
[list
,ndarray
,float
]) – Length of frequency discretizations (\(\Delta \omega\)) for each dimension of size n_dimensions.n_time_intervals (
Union
[list
,ndarray
,float
]) – Number of time discretizations for each dimensions of size n_dimensions.n_frequency_intervals (
Union
[list
,ndarray
,float
]) – Number of frequency discretizations for each dimension of size n_dimensions.random_state (
Union
[None
,int
,RandomState
]) – Random seed used to initialize the pseudo-random number generator. Default isNone
. If anint
is provided, this sets the seed for an object ofnumpy.random.RandomState
. Otherwise, the object itself can be passed directly.
- run(n_samples)[source]
Execute the random sampling in the
SpectralRepresentation
class.The
run()
method is the function that performs random sampling in theSpectralRepresentation
class. If n_samples is provided when theSpectralRepresentation
object is defined, therun()
method is automatically called. The user may also call therun()
method directly to generate samples. Therun()
method of theSpectralRepresentation
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 thesamples
attribute of theSpectralRepresentation
class.
Attributes
-
SpectralRepresentation.samples:
ndarray
Generated samples. The shape of the samples is
(n_samples, n_variables, n_time_intervals[0], ..., n_time_intervals[n_dimensions-1])