KLExpansion#

class cuqi.geometry.KLExpansion(grid=None, decay_rate=2.5, normalizer=12.0, num_modes=None, axis_labels=None, **kwargs)#

Class representation of the random field in the sine basis

\[ \begin{align}\begin{aligned}f = \sum_{i=0}^{N-2} \left(\frac{1}{(i+1)^\gamma\tau}\right) p_i \, \text{sin}\left(\frac{\pi}{N}(i+1)(K+\frac{1}{2})\right)\\+ \frac{(-1)^K}{2}\left(\frac{1}{N^\gamma\tau}\right) p_{N-1}\end{aligned}\end{align} \]

where:

\[\gamma = \text{decay_rate},\]
\[\tau = \text{normalizer},\]

\(K=\{0, 1, 2, 3, ..., N-1\}\), \(N\) is the number of nodes in the grid, and \(p_i\) are the expansion coefficients.

The above transformation is the inverse of DST-II (see https://en.wikipedia.org/wiki/Discrete_sine_transform)

Parameters:
  • grid (array-like or None) – One dimensional regular grid on which the random field is defined. If grid is None, the user will need to set the grid attribute after initialization to be able to fully use the KLExpansion functionalities.

  • decay_rate (float, default 2.5) – The decay rate of the basis functions.

  • normalizer (float, default 1.0) – A factor of the basis functions shown in the formula above.

  • num_modes (int, default None) – Number of expansion modes to use in the KL expansion. If num_modes is None or larger than the number of grid points, all modes will be used.

__init__(grid=None, decay_rate=2.5, normalizer=12.0, num_modes=None, axis_labels=None, **kwargs)#

Methods

__init__([grid, decay_rate, normalizer, ...])

fun2par(funvals)

The function to parameter map used to map function values back to parameters.

fun2vec(funvals)

Maps function values to a vector representation of the function values, if available.

par2fun(p)

The parameter to function map used to map parameters to function values in e.g. plotting.

plot(values[, is_par, plot_par])

Plots a function over the set defined by the geometry object.

plot_envelope(lo_values, hi_values[, ...])

Plots an envelope from lower and upper bounds over the set defined by the geometry object.

vec2fun(funvec)

Maps function vector representation, if available, to function values.

Attributes

coefs

Computes the deterministic part of the expansion coefficients.

coefs_inverse

Computes the inverse of the coefficients diagonal matrix.

decay_rate

fun_dim

The dimension of the geometry (function space).

fun_is_array

Flag to indicate whether the function value is an array.

fun_shape

The shape of the geometry (function space).

funvec_dim

The dimension of the geometry (dimension of the vector representation of the function value).

funvec_shape

The shape of the geometry (shape of the vector representation of the function value).

grid

normalizer

num_modes

Number of expansion modes to use in the KL expansion.

par_dim

The dimension of the geometry (parameter space).

par_shape

The shape of the parameter space

variables