KarhunenLoeveSVDAlgorithm¶
(Source code, png, hires.png, pdf)

class
KarhunenLoeveSVDAlgorithm
(*args)¶ Computation of KarhunenLoeve decomposition using SVD approximation.
 Available constructors:
KarhunenLoeveSVDAlgorithm(sample, s, centeredFlag)
KarhunenLoeveSVDAlgorithm(sample, verticesWeights, s, centeredFlag)
KarhunenLoeveSVDAlgorithm(sample, verticesWeights, sampleWeights, s, centeredFlag)
Parameters:  sample :
ProcessSample
The sample containing the observations.
 verticesWeights : sequence of float
The weights associated to the vertices of the mesh defining the sample.
 sampleWeights : sequence of float
The weights associated to the fields of the sample.
 s : float,
The threshold used to select the most significant eigenmodes, defined in
KarhunenLoeveAlgorithm
. centeredFlag : bool
Flag to tell if the sample is drawn according to a centered process or if it has to be centered using the empirical mean. The default value is False.
Notes
The KarhunenLoeve SVD algorithm solves the Fredholm problem associated to the covariance function : see
KarhunenLoeveAlgorithm
to get the notations.The SVD approach is a particular case of the quadrature approach (see
KarhunenLoeveQuadratureAlgorithm
) where we consider the functional basis of defined on by:The SVD approach is used when the covariance function is not explicitely known but only through fields of the associated stochastic process : .
It consists in :
 approximating by its empirical estimator where and if the process is centered and otherwise, where ;
 taking the vertices of the mesh of as the quadrature points.
We suppose now that , and we note .
As the matrix is invertible, the Galerkin and collocation approaches are equivalent and both lead to the following singular value problem for :
(1)¶
The SVD decomposition of writes:
where we have , , such that :
 ,
 ,
 .
Then the columns of are the eigenvectors of associated to the eigenvalues .
We deduce the modes and eigenvalues of the Fredholm problem for :
We have:
The most computationally intensive part of the algorithm is the computation of the SVD decomposition. By default, it is done using LAPACK dgesdd routine. While being very accurate and reasonably fast for small to medium sized problems, it becomes prohibitively slow for large cases. The user can choose to use a stochastic algorithm instead, with the constraint that the number of singular values to be computed has to be fixed a priori. The following keys of
ResourceMap
allow to select and tune these algorithms: ‘KarhunenLoeveSVDAlgorithmUseRandomSVD’ which triggers the use of a random algorithm. By default, it is set to False and LAPACK is used.
 ‘KarhunenLoeveSVDAlgorithmRandomSVDMaximumRank’ which fixes the number of singular values to compute. By default it is set to 1000.
 ‘KarhunenLoeveSVDAlgorithmRandomSVDVariant’ which can be equal to either ‘halko2010’ for [halko2010] (the default) or ‘halko2011’ for [halko2011]. These two algorithms have very similar structures, the first one being based on a random compression of both the rows and columns of , the second one being based on an iterative compressed sampling of the columns of .
 ‘KarhunenLoeveSVDAlgorithmhalko2011Margin’ and ‘KarhunenLoeveSVDAlgorithmhalko2011Iterations’ to fix the parameters of the ‘halko2011’ variant. See [halko2011] for the details.
Examples
Create a KarhunenLoeve SVD algorithm:
>>> import openturns as ot >>> mesh = ot.IntervalMesher([10]*2).build(ot.Interval([1.0]*2, [1.0]*2)) >>> s = 0.01 >>> model = ot.AbsoluteExponential([1.0]*2) >>> sample = ot.GaussianProcess(model, mesh).getSample(8) >>> algorithm = ot.KarhunenLoeveSVDAlgorithm(sample, s)
Run it!
>>> algorithm.run() >>> result = algorithm.getResult()
Attributes: thisown
The membership flag
Methods
getClassName
()Accessor to the object’s name. getCovarianceModel
()Accessor to the covariance model. getId
()Accessor to the object’s id. getName
()Accessor to the object’s name. getResult
()Get the result structure. getSample
()Accessor to the process sample. getSampleWeights
()Accessor to the weights of the sample. getShadowedId
()Accessor to the object’s shadowed id. getThreshold
()Accessor to the threshold used to select the most significant eigenmodes. getVerticesWeights
()Accessor to the weights of the vertices. getVisibility
()Accessor to the object’s visibility state. hasName
()Test if the object is named. hasVisibleName
()Test if the object has a distinguishable name. run
()Computation of the eigenvalues and eigenfunctions values at nodes. setCovarianceModel
(covariance)Accessor to the covariance model. setName
(name)Accessor to the object’s name. setShadowedId
(id)Accessor to the object’s shadowed id. setThreshold
(threshold)Accessor to the limit ratio on eigenvalues. setVisibility
(visible)Accessor to the object’s visibility state. 
__init__
(*args)¶ Initialize self. See help(type(self)) for accurate signature.

getClassName
()¶ Accessor to the object’s name.
Returns:  class_name : str
The object class name (object.__class__.__name__).

getCovarianceModel
()¶ Accessor to the covariance model.
Returns:  covModel :
CovarianceModel
The covariance model.
 covModel :

getId
()¶ Accessor to the object’s id.
Returns:  id : int
Internal unique identifier.

getName
()¶ Accessor to the object’s name.
Returns:  name : str
The name of the object.

getResult
()¶ Get the result structure.
Returns:  resKL :
KarhunenLoeveResult
The structure containing all the results of the Fredholm problem.
Notes
The structure contains all the results of the Fredholm problem.
 resKL :

getSample
()¶ Accessor to the process sample.
Returns:  sample :
ProcessSample
The process sample containing the observations of the process.
 sample :

getSampleWeights
()¶ Accessor to the weights of the sample.
Returns:  weights :
Point
The weights associated to the fields of the sample.
Notes
The fields might not have the same weight, for example if they come from importance sampling.
 weights :

getShadowedId
()¶ Accessor to the object’s shadowed id.
Returns:  id : int
Internal unique identifier.

getThreshold
()¶ Accessor to the threshold used to select the most significant eigenmodes.
Returns:  s : float, positive
The threshold .
Notes
OpenTURNS truncates the sequence at the index defined in (3).

getVerticesWeights
()¶ Accessor to the weights of the vertices.
Returns:  weights :
Point
The weights associated to the vertices of the mesh defining the sample field.
Notes
The vertices might not have the same weight, for example if the mesh is not regular.
 weights :

getVisibility
()¶ Accessor to the object’s visibility state.
Returns:  visible : bool
Visibility flag.

hasName
()¶ Test if the object is named.
Returns:  hasName : bool
True if the name is not empty.

hasVisibleName
()¶ Test if the object has a distinguishable name.
Returns:  hasVisibleName : bool
True if the name is not empty and not the default one.

run
()¶ Computation of the eigenvalues and eigenfunctions values at nodes.
Notes
Runs the algorithm and creates the result structure
KarhunenLoeveResult
.

setCovarianceModel
(covariance)¶ Accessor to the covariance model.
Parameters:  covModel :
CovarianceModel
The covariance model.
 covModel :

setName
(name)¶ Accessor to the object’s name.
Parameters:  name : str
The name of the object.

setShadowedId
(id)¶ Accessor to the object’s shadowed id.
Parameters:  id : int
Internal unique identifier.

setThreshold
(threshold)¶ Accessor to the limit ratio on eigenvalues.
Parameters:  s : float,
The threshold defined in (3).

setVisibility
(visible)¶ Accessor to the object’s visibility state.
Parameters:  visible : bool
Visibility flag.

thisown
¶ The membership flag