LinearLeastSquaresCalibration¶
-
class
LinearLeastSquaresCalibration
(*args)¶ Linear least squares calibration algorithm.
- Available constructors:
LinearLeastSquaresCalibration(model, inputObservations, outputObservations, candidate, methodName)
LinearLeastSquaresCalibration(modelObservations, gradientObservations, outputObservations, candidate, methodName)
- 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 reference value of the parameter.
- methodNamestr
The name of the least-squares method to use for the calibration. By default, equal to QR. Possible values are SVD, QR, Cholesky.
- model
Notes
LinearLeastSquaresCalibration is the minimum variance estimator of the parameter of a given model under the assumption that this parameter acts linearly in the model.
The prior distribution of the parameter is a
Dirac
.The posterior distribution of the parameter is
Normal
and reflects the variability of the optimum parameter depending on the observation sample. The associated covariance matrix may be regularized depending on the value of the key LinearLeastSquaresCalibration-Regularization in theResourceMap
. Let us denote by the smallest singular value of the covariance matrix. The default value of the LinearLeastSquaresCalibration-Regularization, zero, ensures that the singular values of the covariance matrix are left unmodified. If this parameter is set to a nonzero, relatively small, value denoted by , then all singular values of the covariance matrix are increased by .The resulting distribution of the output error is
Normal
with a zero mean and a diagonal covariance matrix computed from the residuals. The residuals are computed based on the linearization of the model, where the Jacobian matrix is evaluated at the candidate point. The diagonal of the diagonal covariance matrix of the output error is contant and is estimated with the unbiased variance estimator.Examples
Calibrate a nonlinear model using linear least-squares:
>>> 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 >>> method = 'SVD' >>> algo = ot.LinearLeastSquaresCalibration(modelX, x, y, candidate, method) >>> algo.run() >>> print(algo.getResult().getParameterMAP()) [8.24019,0.0768046,0.992957]
Methods
getCandidate
(self)Accessor to the parameter candidate.
getClassName
(self)Accessor to the object’s name.
getGradientObservations
(self)Accessor to the model gradient at the candidate.
getId
(self)Accessor to the object’s id.
getMethodName
(self)Accessor to the name of least-squares method used for the resolution.
getModelObservations
(self)Accessor to the model evaluation at the candidate.
getName
(self)Accessor to the object’s name.
getOutputObservations
(self)Accessor to the output data to be fitted.
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)Launch the algorithm.
setName
(self, name)Accessor to the object’s name.
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.
-
getClassName
(self)¶ Accessor to the object’s name.
- Returns
- class_namestr
The object class name (object.__class__.__name__).
-
getGradientObservations
(self)¶ Accessor to the model gradient at the candidate.
- Returns
- gradientObservation
Matrix
Gradient of the model at the candidate point.
- gradientObservation
-
getId
(self)¶ Accessor to the object’s id.
- Returns
- idint
Internal unique identifier.
-
getMethodName
(self)¶ Accessor to the name of least-squares method used for the resolution.
- Returns
- name
String
Name of least-squares method used for the resolution.
- name
-
getModelObservations
(self)¶ Accessor to the model evaluation at the candidate.
- Returns
- modelObservation
Sample
Evaluation of the model at the candidate point.
- modelObservation
-
getName
(self)¶ Accessor to the object’s name.
- Returns
- namestr
The name of the object.
-
getOutputObservations
(self)¶ Accessor to the output data to be fitted.
- Returns
- data
Sample
The output data to be fitted.
- data
-
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)¶ Launch the algorithm.
Notes
It launches the algorithm and creates a
CalibrationResult
, structure containing all the results.
-
setName
(self, name)¶ Accessor to the object’s name.
- Parameters
- namestr
The name of the object.
-
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.