RankMCovarianceModel¶
(Source code, png, hires.png, pdf)
-
class
RankMCovarianceModel
(*args)¶ Covariance function of finite rank.
- Available constructors:
RankMCovarianceModel(inputDimension)
RankMCovarianceModel(variance, basis)
RankMCovarianceModel(covariance, basis)
- Parameters
- variancesequence of float
The marginal variances of the coefficients of the basis.
- covariance
CovarianceMatrix
The covariance of the coefficients of the basis.
Notes
Let be a stochastic process defined by:
where is a random vector of dimension and are the first elements of a given basis.
Its covariance function, a rank-M covariance function, is given by:
where is the covariance matrix of .
When is diagonal, it reduces to:
where is the variance of .
The name rank-M is here to recall that the discretization of such a model will always lead to a covariance matrix of rank at most .
Examples
>>> import openturns as ot >>> variance = [1.0, 2.0] >>> basis = ot.LinearBasisFactory().build() >>> myCovarianceModel = ot.RankMCovarianceModel(variance, basis) >>> covariance = ot.CovarianceMatrix(2, [1.0, 0.5, 0.5, 2.0]) >>> covarianceModel = ot.RankMCovarianceModel(covariance, basis)
Methods
__call__
(self, \*args)Evaluate the covariance function.
computeAsScalar
(self, s, t)Compute the covariance function for scalar model.
computeStandardRepresentative
(self, s, t)Compute the standard representative function of the covariance model.
discretize
(self, \*args)Discretize the covariance function on a given mesh.
discretizeAndFactorize
(self, \*args)Discretize and factorize the covariance function on a given mesh.
discretizeAndFactorizeHMatrix
(self, \*args)Discretize and factorize the covariance function on a given mesh.
discretizeHMatrix
(self, \*args)Discretize the covariance function on a given mesh using HMatrix result.
discretizeRow
(self, vertices, p)(TODO)
draw
(self, \*args)Draw a specific component of the covariance model with input dimension 1.
getActiveParameter
(self)Accessor to the active parameter set.
getAmplitude
(self)Get the amplitude parameter of the covariance function.
getBasis
(self)Accessor to the Basis.
getClassName
(self)Accessor to the object’s name.
getCovariance
(self)Covariance accessor.
getFullParameter
(self)Get the full parameters of the covariance function.
Get the description full parameters of the covariance function.
getFunctions
(self)Function collection accessor.
getId
(self)Accessor to the object’s id.
getInputDimension
(self)Get the input dimension of the covariance function.
getMarginal
(self, \*args)Get the ith marginal of the model.
getName
(self)Accessor to the object’s name.
getNuggetFactor
(self)Accessor to the nugget factor.
getOutputCorrelation
(self)Get the spatial correlation matrix of the covariance function.
getOutputDimension
(self)Get the dimension of the covariance function.
getParameter
(self)Get the parameters of the covariance function.
getParameterDescription
(self)Get the description of the covariance function parameters.
getScale
(self)Get the scale parameter of the covariance function.
getShadowedId
(self)Accessor to the object’s shadowed id.
getVariance
(self)Variance accessor.
getVisibility
(self)Accessor to the object’s visibility state.
hasName
(self)Test if the object is named.
hasVisibleName
(self)Test if the object has a distinguishable name.
isDiagonal
(self)Test whether the model is diagonal or not.
isStationary
(self)Test whether the model is stationary or not.
parameterGradient
(self, s, t)Compute the gradient according to the parameters.
partialGradient
(self, s, t)Compute the gradient of the covariance function.
setActiveParameter
(self, active)Accessor to the active parameter set.
setAmplitude
(self, amplitude)Set the amplitude parameter of the covariance function.
setFullParameter
(self, parameter)Set the full parameters of the covariance function.
setName
(self, name)Accessor to the object’s name.
setNuggetFactor
(self, nuggetFactor)Set the nugget factor for the variance of the observation error.
setOutputCorrelation
(self, correlation)Set the spatial correlation matrix of the covariance function.
setParameter
(self, parameter)Set the parameters of the covariance function.
setScale
(self, scale)Set the scale parameter of the covariance function.
setShadowedId
(self, id)Accessor to the object’s shadowed id.
setVisibility
(self, visible)Accessor to the object’s visibility state.
-
__init__
(self, \*args)¶ Initialize self. See help(type(self)) for accurate signature.
-
computeAsScalar
(self, s, t)¶ Compute the covariance function for scalar model.
- Available usages:
computeAsScalar(s, t)
computeAsScalar(tau)
- Parameters
- s, tsequences of float
Multivariate index
- tausequence of float
Multivariate index
- Returns
- covariancefloat
Covariance.
Notes
The method makes sense only if the dimension of the process is . It evaluates .
In the second usage, the covariance model must be stationary. Then we note for as this quantity does not depend on .
-
computeStandardRepresentative
(self, s, t)¶ Compute the standard representative function of the covariance model.
- Available usages:
computeStandardRepresentative(s, t)
computeStandardRepresentative(tau)
- Parameters
- s, tsequences of float
Multivariate index
- taufloat or sequence of float
Multivariate index
- Returns
- rhofloat
Correlation model
Notes
It evaluates the scalar function or if the model is stationary.
-
discretize
(self, \*args)¶ Discretize the covariance function on a given mesh.
- Parameters
- meshOrGrid
Mesh
orRegularGrid
Mesh or time grid of size associated with the process.
- meshOrGrid
- Returns
- covarianceMatrix
CovarianceMatrix
Covariance matrix (if the process is of dimension
- covarianceMatrix
Notes
This method makes a discretization of the model on meshOrGrid composed of the vertices and returns the covariance matrix:
-
discretizeAndFactorize
(self, \*args)¶ Discretize and factorize the covariance function on a given mesh.
- Parameters
- meshOrGrid
Mesh
orRegularGrid
Mesh or time grid of size associated with the process.
- meshOrGrid
- Returns
- CholeskyMatrix
TriangularMatrix
Cholesky factor of the covariance matrix (if the process is of dimension ).
- CholeskyMatrix
Notes
This method makes a discretization of the model on meshOrGrid composed of the vertices thanks to the discretize method and returns its Cholesky factor.
-
discretizeAndFactorizeHMatrix
(self, \*args)¶ Discretize and factorize the covariance function on a given mesh.
This uses HMatrix.
- Parameters
- meshOrGrid
Mesh
orRegularGrid
Mesh or time grid of size associated with the process.
- hmatParam
HMatrixParameters
Parameter values for the HMatrix
- meshOrGrid
- Returns
- HMatrix
HMatrix
Cholesk matrix (if the process is of dimension ), stored in hierarchical format (H-Matrix)
- HMatrix
Notes
This method si similar to the discretizeAndFactorize method. This method requires that OpenTURNS has been compiled with the hmat library. The method is helpfull for very large parameters (Mesh, grid, Sample) as its compress data.
-
discretizeHMatrix
(self, \*args)¶ Discretize the covariance function on a given mesh using HMatrix result.
- Parameters
- meshOrGrid
Mesh
orRegularGrid
Mesh or time grid of size associated with the process.
- hmatParam
HMatrixParameters
Parameter values for the HMatrix
- meshOrGrid
- Returns
- HMatrix
HMatrix
Covariance matrix (if the process is of dimension ), stored in hierarchical format (H-Matrix)
- HMatrix
Notes
This method si similar to the discretize method. This method requires that OpenTURNS has been compiled with the hmat library. The method is helpfull for very large parameters (Mesh, grid, Sample) as its compress data.
-
discretizeRow
(self, vertices, p)¶ (TODO)
-
draw
(self, \*args)¶ Draw a specific component of the covariance model with input dimension 1.
- Parameters
- rowIndexint,
The row index of the component to draw. Default value is 0.
- columnIndex: int, :math:`0 leq columnIndex < dimension`
The column index of the component to draw. Default value is 0.
- tMinfloat
The lower bound of the range over which the model is plotted. Default value is CovarianceModel-DefaultTMin in
ResourceMap
.- tMaxfloat
The upper bound of the range over which the model is plotted. Default value is CovarianceModel-DefaultTMax in
ResourceMap
.- pointNumberint,
The discretization of the range over which the model is plotted. Default value is CovarianceModel-DefaultPointNumber in class:~openturns.ResourceMap.
- asStationarybool
Flag to tell if the model has to be plotted as a stationary model, ie as a function of the lag if equals to True, or as a non-stationary model, ie as a function of if equals to False. Default value is True.
- correlationFlagbool
Flag to tell if the model has to be plotted as a correlation function if equals to True or as a covariance function if equals to False. Default value is False.
- Returns
- graph
Graph
A graph containing a unique curve if asStationary=True and if the model is actually a stationary model, or containing the iso-values of the model if asStationary=False or if the model is nonstationary.
- graph
-
getActiveParameter
(self)¶ Accessor to the active parameter set.
- Returns
- active
Indices
Indices of the active parameters.
- active
-
getAmplitude
(self)¶ Get the amplitude parameter of the covariance function.
- Returns
- amplitude
Point
The amplitude parameter of the covariance function.
- amplitude
-
getClassName
(self)¶ Accessor to the object’s name.
- Returns
- class_namestr
The object class name (object.__class__.__name__).
-
getCovariance
(self)¶ Covariance accessor.
- Returns
- covariance
CovarianceMatrix
Covariance matrix of . Its dimension is zero if the coefficients are uncorrelated, in which case the marginal variances are given by getVariance().
- covariance
-
getFullParameter
(self)¶ Get the full parameters of the covariance function.
- Returns
- parameter
Point
List the full parameter of the covariance function i.e. scale parameter , the the amplitude parameter , the Spatial correlation parameter ; and potential other parameter depending on the model;
- parameter
-
getFullParameterDescription
(self)¶ Get the description full parameters of the covariance function.
- Returns
- description
Description
Description of the full parameter of the covariance function.
- description
-
getFunctions
(self)¶ Function collection accessor.
- Returns
- functions
FunctionCollection
The collection of functions defining the covariance model.
- functions
-
getId
(self)¶ Accessor to the object’s id.
- Returns
- idint
Internal unique identifier.
-
getInputDimension
(self)¶ Get the input dimension of the covariance function.
- Returns
- inputDimensionint
Spatial dimension of the covariance function.
-
getMarginal
(self, \*args)¶ Get the ith marginal of the model.
- Returns
- marginalint or sequence of int
index of marginal of the model.
-
getName
(self)¶ Accessor to the object’s name.
- Returns
- namestr
The name of the object.
-
getNuggetFactor
(self)¶ Accessor to the nugget factor.
This parameter allows smooth predictions from noisy data. The nugget is added to the diagonal of the assumed training covariance (thanks to discretize) and acts as a Tikhonov regularization in the problem.
- Returns
- nuggetFactorfloat
Nugget factor used to model the observation error variance.
-
getOutputCorrelation
(self)¶ Get the spatial correlation matrix of the covariance function.
- Returns
- spatialCorrelation
CorrelationMatrix
Correlation matrix .
- spatialCorrelation
-
getOutputDimension
(self)¶ Get the dimension of the covariance function.
- Returns
- dint
Dimension such that This is the dimension of the process .
-
getParameter
(self)¶ Get the parameters of the covariance function.
- Returns
- parameters
Point
List of the scale parameter and the amplitude parameter of the covariance function.
The other specific parameters are not included.
- parameters
-
getParameterDescription
(self)¶ Get the description of the covariance function parameters.
- Returns
- descriptionParam
Description
Description of the components of the parameters obtained with the getParameter method..
- descriptionParam
-
getScale
(self)¶ Get the scale parameter of the covariance function.
- Returns
- scale
Point
The scale parameter used in the covariance function.
- scale
-
getShadowedId
(self)¶ Accessor to the object’s shadowed id.
- Returns
- idint
Internal unique identifier.
-
getVariance
(self)¶ Variance accessor.
- Returns
- variance
Point
Vector of marginal variances of . Its dimension is zero if the coefficients are correlated, in which case the covariance matrix is given by getCovariance().
- variance
-
getVisibility
(self)¶ Accessor to the object’s visibility state.
- Returns
- visiblebool
Visibility flag.
-
hasName
(self)¶ Test if the object is named.
- Returns
- hasNamebool
True if the name is not empty.
-
hasVisibleName
(self)¶ Test if the object has a distinguishable name.
- Returns
- hasVisibleNamebool
True if the name is not empty and not the default one.
-
isDiagonal
(self)¶ Test whether the model is diagonal or not.
- Returns
- isDiagonalbool
True if the model is diagonal.
-
isStationary
(self)¶ Test whether the model is stationary or not.
- Returns
- isStationarybool
True if the model is stationary.
Notes
The covariance function is stationary when it is invariant by translation:
We note for .
-
parameterGradient
(self, s, t)¶ Compute the gradient according to the parameters.
- Parameters
- s, tsequences of float
Multivariate index .
- Returns
- gradient
Matrix
Gradient of the function according to the parameters.
- gradient
-
partialGradient
(self, s, t)¶ Compute the gradient of the covariance function.
- Parameters
- s, tfloats or sequences of float
Multivariate index .
- Returns
- gradient
Matrix
Gradient of the covariance function.
- gradient
-
setActiveParameter
(self, active)¶ Accessor to the active parameter set.
- Parameters
- activesequence of int
Indices of the active parameters.
-
setAmplitude
(self, amplitude)¶ Set the amplitude parameter of the covariance function.
- Parameters
- amplitude
Point
The amplitude parameter to be used in the covariance function. Its size must be equal to the dimension of the covariance function.
- amplitude
-
setFullParameter
(self, parameter)¶ Set the full parameters of the covariance function.
- Parameters
- parameter
Point
List the full parameter of the covariance function i.e. scale parameter , the the amplitude parameter , the Spatial correlation parameter ; and potential other parameter depending on the model;
Must be at least of dimension .
- parameter
-
setName
(self, name)¶ Accessor to the object’s name.
- Parameters
- namestr
The name of the object.
-
setNuggetFactor
(self, nuggetFactor)¶ Set the nugget factor for the variance of the observation error.
Acts on the discretized covariance matrix.
- Parameters
- nuggetFactorfloat
nugget factor to be used to model the variance of the observation error.
-
setOutputCorrelation
(self, correlation)¶ Set the spatial correlation matrix of the covariance function.
- Parameters
- spatialCorrelation
CorrelationMatrix
Correlation matrix .
- spatialCorrelation
-
setParameter
(self, parameter)¶ Set the parameters of the covariance function.
- Parameters
- parameters
Point
List of the scale parameter and the amplitude parameter of the covariance function.
Must be of dimension .
- parameters
-
setScale
(self, scale)¶ Set the scale parameter of the covariance function.
- Parameters
- scale
Point
The scale parameter to be used in the covariance function. Its size must be equal to the input dimension of the covariance function.
- scale
-
setShadowedId
(self, id)¶ Accessor to the object’s shadowed id.
- Parameters
- idint
Internal unique identifier.
-
setVisibility
(self, visible)¶ Accessor to the object’s visibility state.
- Parameters
- visiblebool
Visibility flag.