GaussianNonLinearCalibration¶
-
class
GaussianNonLinearCalibration
(*args)¶ Gaussian non linear calibration algorithm (3DVAR).
- Parameters
- model
Function
The parametric function to be calibrated.
- inputObservations2-d sequence of float
The sample of input observations.
- outputObservations2-d sequence of float
The sample of output observations.
- candidatesequence of float
The mean of the gaussian prior distribution of the parameter.
- parameterCovariance2-d sequence of float
The covariance matrix of the gaussian prior distribution of the parameter.
- errorCovariance2-d sequence of float
The covariance matrix of the gaussian distribution of the observations error.
- model
Notes
GaussianNonLinearCalibration is the minimum variance estimator of the parameter of a given model under the assumption that this parameter is dispersed according to a known covariance matrix. This algorithm is also known as 3DVAR.
The given observation error covariance can be either local, ie the same matrix applies for each observation and is of dimension the output dimension of the model, or global, ie the matrix describes the full set of observation errors, in which case its dimension is the product of the output dimension of the model and the number of observations.
The prior distribution of the parameter is a
Normal
.The posterior distribution of the parameter is
Normal
. By default, the posterior distribution is evaluated based on a linear approximation of the model at the optimum. This corresponds to using theGaussianLinearCalibration
at the optimum, and is named Laplace approximation in the bayesian context. However, if the key GaussianNonLinearCalibration-BootstrapSize in theResourceMap
is set to a nonzero positive integer, then a bootstrap resampling of the observations is performed and the posterior distribution is based on aKernelSmoothing
of the sample of boostrap optimum parameters.The resulting error distribution is
Normal
and is based on the errorCovariance input argument.Examples
Calibrate a nonlinear model using 3DVAR:
>>> import openturns as ot >>> ot.RandomGenerator.SetSeed(0) >>> m = 10 >>> x = [[0.5 + i] for i in range(m)] >>> inVars = ['a', 'b', 'c', 'x'] >>> formulas = ['a + b * exp(c * x)'] >>> model = ot.SymbolicFunction(inVars, formulas) >>> p_ref = [2.8, 1.2, 0.5] >>> params = [0, 1, 2] >>> modelX = ot.ParametricFunction(model, params, p_ref) >>> y = modelX(x) >>> y += ot.Normal(0.0, 0.05).getSample(m) >>> candidate = [1.0]*3 >>> priorCovariance = ot.CovarianceMatrix(3) >>> errorCovariance = ot.CovarianceMatrix(1, [0.1]) >>> algo = ot.GaussianNonLinearCalibration(modelX, x, y, candidate, priorCovariance, errorCovariance) >>> algo.run() >>> print(algo.getResult().getParameterMAP()) [2.705...,1.212...,0.499...]
Methods
getBootstrapSize
(self)Accessor to the bootstrap size used to sample the posterior distribution.
getCandidate
(self)Accessor to the parameter candidate.
getClassName
(self)Accessor to the object’s name.
getErrorCovariance
(self)Accessor to the observation error covariance.
getGlobalErrorCovariance
(self)Accessor to the flag for a global observation error covariance.
getId
(self)Accessor to the object’s id.
getName
(self)Accessor to the object’s name.
getOptimizationAlgorithm
(self)Accessor to the optimization algorithm used for the computation.
getOutputObservations
(self)Accessor to the output data to be fitted.
getParameterCovariance
(self)Accessor to the parameter prior covariance.
getParameterPrior
(self)Accessor to the parameter prior distribution.
getResult
(self)Get the result structure.
getShadowedId
(self)Accessor to the object’s shadowed id.
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.
run
(self, \*args)Launch the algorithm.
setBootstrapSize
(self, bootstrapSize)Accessor to the bootstrap size used to sample the posterior distribution.
setName
(self, name)Accessor to the object’s name.
setOptimizationAlgorithm
(self, algorithm)Accessor to the optimization algorithm used for the computation.
setResult
(self, result)Accessor to optimization result.
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.
-
getBootstrapSize
(self)¶ Accessor to the bootstrap size used to sample the posterior distribution.
- Returns
- sizeint
Bootstrap size used to sample the posterior distribution. A value of 0 means that no bootstrap has been done but a linear approximation has been used to get the posterior distribution, using the
GaussianLinearCalibration
algorithm at the maximum a posteriori estimate.
-
getClassName
(self)¶ Accessor to the object’s name.
- Returns
- class_namestr
The object class name (object.__class__.__name__).
-
getErrorCovariance
(self)¶ Accessor to the observation error covariance.
- Returns
- error
CovarianceMatrix
Observation error covariance.
- error
-
getGlobalErrorCovariance
(self)¶ Accessor to the flag for a global observation error covariance.
- Returns
- flagbool
Flag telling if the given observation error covariance is global or not.
-
getId
(self)¶ Accessor to the object’s id.
- Returns
- idint
Internal unique identifier.
-
getName
(self)¶ Accessor to the object’s name.
- Returns
- namestr
The name of the object.
-
getOptimizationAlgorithm
(self)¶ Accessor to the optimization algorithm used for the computation.
- Returns
- algo
OptimizationAlgorithm
Optimization algorithm used for the computation.
- algo
-
getOutputObservations
(self)¶ Accessor to the output data to be fitted.
- Returns
- data
Sample
The output data to be fitted.
- data
-
getParameterCovariance
(self)¶ Accessor to the parameter prior covariance.
- Returns
- prior
CovarianceMatrix
Parameter prior covariance.
- prior
-
getParameterPrior
(self)¶ Accessor to the parameter prior distribution.
- Returns
- prior
Distribution
The parameter prior distribution.
- prior
-
getResult
(self)¶ Get the result structure.
- Returns
- resCalibration:
CalibrationResult
The structure containing all the results of the calibration problem.
- resCalibration:
Notes
The structure contains all the results of the calibration problem.
-
getShadowedId
(self)¶ Accessor to the object’s shadowed id.
- Returns
- idint
Internal unique identifier.
-
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.
-
run
(self, \*args)¶ Launch the algorithm.
Notes
It launches the algorithm and creates a
CalibrationResult
, structure containing all the results.
-
setBootstrapSize
(self, bootstrapSize)¶ Accessor to the bootstrap size used to sample the posterior distribution.
- Parameters
- sizeint
Bootstrap size used to sample the posterior distribution. A value of 0 means that no bootstrap has to be done but a linear approximation has been used to get the posterior distribution, using the
GaussianLinearCalibration
algorithm at the maximum a posteriori estimate.
-
setName
(self, name)¶ Accessor to the object’s name.
- Parameters
- namestr
The name of the object.
-
setOptimizationAlgorithm
(self, algorithm)¶ Accessor to the optimization algorithm used for the computation.
- Parameters
- algo
OptimizationAlgorithm
Optimization algorithm to use for the computation.
- algo
-
setResult
(self, result)¶ Accessor to optimization result.
- Parameters
- result
CalibrationResult
Result class.
- result
-
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.